Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Done
-
None
-
Major Change
-
Query 11 (03/14/16), Query 12 (04/04/16)
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
Attachments
Issue Links
- is documented by
-
DOCS-8930 lookup between local (multiple)array of values and foreign (single) value
-
- Closed
-
- is duplicated by
-
SERVER-21469 $lookup is not working in case of the localField is array
-
- Closed
-
-
SERVER-23180 array in $lookup localField should not be interpreted literally
-
- Closed
-
- is related to
-
SERVER-32494 $lookup should have option not merge duplicate array item in result (not auto unique)
-
- Closed
-
- related to
-
DOCS-12756 Update documentation regarding using $lookup on array as localField
-
- Closed
-