2

I want to do a $lookup where the localField is a String representation of an ObjectId and the foreign field is an actual ObjectId.

Any idea if this is possible with MongoDB 3.2 if items is a String value but _id is an ObjectId?

[{
    "$lookup": {
        "from": "videos",
        "localField": "items",
        "foreignField": "_id",
        "as": "appendedItems"
    }
}]
Cade Embery
  • 433
  • 1
  • 5
  • 18

1 Answers1

2

It is not possible to match string with ObjectId in $lookup in mongodb version 3.2, there are some tickets opened for this issue, you can follow these issue and also vote for them.

https://jira.mongodb.org/browse/SERVER-22781

https://jira.mongodb.org/browse/SERVER-24947

Puneet Singh
  • 3,477
  • 1
  • 26
  • 39