Linked Questions
29 questions linked to/from $lookup multiple levels without $unwind?
2 votes
0 answers
2k views
MongoDB $lookup inside nested array performance & best practice issue [duplicate]
In MongoDB I have: Collection customers with embedded array orders: db.customers.insert([ {_id: 1, name: "John", orders: [ {articleId: 1, quantity: 10}, {articleId: 2, quantity: 5} ]}]); ...
2 votes
0 answers
1k views
How to sort a populated two level deep subdocuments array with mongoose [duplicate]
I'm developping an api with mongoose and nodejs. Basically there is a Course Model, Student Model and Group Model. For every course there is two fields in course document: . Field "students": array ...
0 votes
0 answers
182 views
Joining 2 collection with filtered result in $lookup in pymongo/mongodb [duplicate]
Consider the below three collection in which I have grouped Collection 1 with Collection 2 using $lookup. I am able to get the preowned price for Adidas shoes but when a user selects PUMA shoes then ...
0 votes
1 answer
123 views
Populating all items from ref model [duplicate]
I have a database structured like this: I want to get all listItems, of all lists from a user with a x ID. What's the correct way of doing that? I'm using node with mongoose, and I tried the ...
1 vote
0 answers
133 views
Problem in fetching data from multiple collections using lookup in Mongoose [duplicate]
Currently I have three Collection "User" , "UserLocation" & "UserAddress" which are related with each other. Below are the Schema UserModel var userTable = new Schema({ name: String, email ...
1 vote
0 answers
47 views
Mongodb join elements inside of an array [duplicate]
So basically what I'm trying to achieve is to get tickets from a concert. every ticket has a seller ID which I want to join with the collection users. This is the query I have, to get all the tickets ...
0 votes
0 answers
48 views
How to map back the values from $lookup to local array field? [duplicate]
I would like to map back the valuse from a $lookup operation to local array field. Currently, I am only able to create a standalone array field using $lookup, but not able to map the value back ...
0 votes
1 answer
48 views
How to implement `lookup` in 2nd level in mongoDB? [duplicate]
While trying to use lookup in 2nd level, getting an empty array instead of an object. I have 3 collections, 1. registration 2. bus 3. operator Here, registration contains busId, and the ...
1 vote
0 answers
40 views
How to populate the all sub schemas in a page without using findById? [duplicate]
I have a user schema with the sub-schema called project and inside the project I have another schema called boq. How can I populate boqs and projects all in one page without using findById. I can ...
0 votes
0 answers
27 views
MongoDB lookup 3 collections and nesting the collections [duplicate]
I have 3 collections in a MongoDB instance. I need to join the 3 collections using the lookup operation and I need the collections nested within their respective parent objects. For example, I have ...
1 vote
0 answers
29 views
How to perform operations in pipeline in mongo $lookup [duplicate]
db.getCollection('raw_attom_recorder').aggregate([ { $match: {"RecordingDate": { $gte: ISODate("2018-01-01T00:00:00.000+0000") }} } , { $sort : { AttomId : 1, ...
13 votes
1 answer
18k views
$lookup nested array in mongodb
I am struggling with the newish (lovely) lookup operator in MongoDB. I have 3 collections: artists { "_id" : ObjectId("5b0d2b2c7ac4792df69a9942"), "name" : "Dream Theater", "...
2 votes
1 answer
5k views
Join two tables with selected fields and where clause in mongodb
I have two collections listed below :- table1 {"_id" : ObjectId("5b9a.."), "item_id" :"1.1", "m_date" : "20130401","ref_id":"12R","sub_item_id":"1.1.1"} {"_id" : ObjectId("5c37.."), "item_id" :"1.1",...
1 vote
2 answers
2k views
Mongodb aggregate lookup for many collections to one nested output
I've 3 Collections: School { "id" : { "$numberLong" : "100000" }, "name" : "School1" } Faculty { "id" : { "$numberLong" : "100000" }, "schoolId" : { "$numberLong" : "100000" },...
1 vote
2 answers
5k views
Mongoose: ref custom field name
I am configuring Mongoose to work on an existing MongoDB, that has these two collections: Users - with fields: _id: ObjectId name: String org_id: ObjectId Organizations - with fields: _id: ObjectId ...