I have a mongo collection with the document format below
{
"_id": {
"objectId": "test1",
"source": "testSource"
},
"val": {
"testField": "fieldValueOne"
}
}
The source value is same for all the documents. I am trying to use $in query as below but it is returning empty set.
db.getCollection('my_collection').find({ "_id": {
"objectId":{"$in": ["test1","test2","test3"]},
"source": "testSource"
}})
But if I do following simple $in query it returns all the matching documents.
db.getCollection('my_collection').find({
"_id.objectId":{"$in": ["test1","test2","test3"]}
}})
But I want to include the source too as in future there can be different source values. How can I achieve the desired query? Thanks in advance.