Details
-
Task
-
Resolution: Won't Fix
-
Trivial - P5
-
None
Description
It is possible to perform multiple $lookups in a single query, on the same collection, on fields that are derived using $addFields. A suggestion was made in a case that perhaps our documentation could be updated to indicate this. For example a query like this is possible:
{$match: {id: {$in: [/^123456/ ,
|
/^123457/
|
]}}},
|
{"$addFields":{
|
"BlockKey": {$concat: [ "L", { $substr: [ "$id", 0, 7 ]}] },
|
"CodeKey": {$concat: [ "L", { $substr: [ "$_id", 0, 6 ]},"A"] }
|
}},
|
{ $lookup: {
|
from: "port_ss_col",
|
localField: "BlockKey",
|
foreignField: "_id",
|
as: "BlockArray"
|
}},
|
{ $lookup: {
|
from: "port_ss_col",
|
localField: "CodeKey",
|
foreignField: "_id",
|
as: "CodeArray"
|
}},
|
{ $project: {...
|
If that's not possible (or if this doc-addition doesn't make sense), that's fine; it's understood that every query use case cannot be included in our documentation. This was just a suggestion that we received.