Hi Aleksey,
Have you tried accessing the id through "_id.$oid" as the foreignField argument?
-Pádraig
Hi Pádraig,
It says: 'FieldPath field names may not start with '$'.
I think, that's impossible: https://jira.mongodb.org/browse/SERVER-14466
Well, I guess, I'll just then insert full {_id {$oid}} structure as a foreign key to the A collection. Like this:
coll A:
{ bCollectionDocId: {_id: { $oid: "231nkren32fko45" }} }
coll B:
{ _id: { $oid: "231nkren32fko45" } }
localField: "bCollectionDocId._id",
foreignField: "_id",
It will take a couple of hours to refactor the code in my project, but at least this solution seems to work.
Aleksey Shishkin
Hi,
I'm trying to join two collections. My first collection has a string field, which contains id of a document in the second collection. Like this:
coll A:
{ bCollectionDocId: "231nkren32fko45"}
coll B:
{ _id: { $oid: "231nkren32fko45" } }
I can't come up with the right $lookup stage when local field is just string (bCollectionDocId) and foreign field is nested structure.
Perhaps, it's not possible at all?