Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

lookup in other document in array

db.orders.aggregate([
    // Unwind the source
    { "$unwind": "$products" },
    // Do the lookup matching
    { "$lookup": {
       "from": "products",
       "localField": "products",
       "foreignField": "_id",
       "as": "productObjects"
    }},
    // Unwind the result arrays ( likely one or none )
    { "$unwind": "$productObjects" },
    // Group back to arrays
    { "$group": {
        "_id": "$_id",
        "products": { "$push": "$products" },
        "productObjects": { "$push": "$productObjects" }
    }}
])
Comment

PREVIOUS NEXT
Code Example
Javascript :: ex: javascript Executor 
Javascript :: nodejs: http: router simple 
Javascript :: convert to slug javascript 
Javascript :: jquery put value in table 
Javascript :: How to export functions and import them in js 
Javascript :: switch javascript to java 
Javascript :: stack array in localStorage 
Javascript :: Warning: Problem validating app.json: Unable to perform cache refresh for 
Javascript :: adding transition to collapse button js 
Javascript :: phaser place on line 
Javascript :: phaser animation from png sequence 
Javascript :: phaser play animation after delay 
Javascript :: .every() Accepts a test function and returns a boolean if all the elements of the array pass the test. 
Javascript :: _.isUndefined 
Javascript :: js undici 
Javascript :: Count the number of child records on the each parent object 
Javascript :: nestjs TS2339 
Javascript :: Using the forEach function In JavaScript 
Javascript :: javascript replace all with variable 
Javascript :: disable input field javascript 
Javascript :: comentar en javascript 
Javascript :: for in loop 
Javascript :: undefined value check in javascript 
Javascript :: underscore.js 
Javascript :: get array from string javascript 
Javascript :: discord.js purge 
Javascript :: set method in javascript 
Javascript :: javascrip functions parameters 
Javascript :: ajax form submit 
Javascript :: know when recyclerview is on the last item 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =