[DOCS-8930]  lookup between local (multiple)array of values and foreign (single) value Created: 28/Sep/16  Updated: 30/Oct/23  Resolved: 05/Jul/19

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-22881 lookup between local (multiple)array... Closed
Duplicate
is duplicated by DOCS-9609 Clarify lookup between local (multipl... Closed
is duplicated by DOCS-10630 Comment on: "manual/reference/operato... Closed
is duplicated by DOCS-12756 Update documentation regarding using ... Closed
Participants:
Days since reply: 7 years, 20 weeks ago
Epic Link: DOCSP-1769

 Description   

Example Order Document:

{
    _id: ObjectId("..."),
    products: [ ObjectId("..<Car ObjectId>.."), ObjectId("..<Bike ObjectId>..") ]
}

Not Working Query:

db.orders.aggregate([ {
    $lookup: {
           from: "products",
           localField: "products",    <= array of IDs
           foreignField: "_id",
           as: "productObjects"
    }
} ])

Desired Result

{
  _id: ObjectId("..."),
  products: [
    ObjectId("..<Car ObjectId>.."),
    ObjectId("..<Bike ObjectId>..")
  ],
  productObjects: [
    {<Car Object>},
    {<Bike Object>}
  ],
}

source: http://stackoverflow.com/questions/34967482/lookup-on-objectids-in-an-array


Generated at Thu Feb 08 07:57:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.