Vote count:
0
I am trying to query on id of embedded array of documents without any success. Would be great to know how to query array of embedded documents using its 'id'.
Below is my collection named sp
{ "_id":ObjectId("54bd949a44ae90d7e1473581"),"orgName":"org name","towns":[{"_id":ObjectId("54bd7829104d630153f66082"),"status":"SUBMITTED","contact":{"name":"con name","email":"con@email.com","phone":"34567890123"}}]}
{ "_id":ObjectId("54bd94ac44ae90d7e1473582"),"orgName":"sp3 org name","towns":[{"_id":ObjectId("54bd7829104d630153f66082"),"status":"SUBMITTED","contact":{"name":"sp3 contact name","email":"sp3con@email.com","phone":"45678903"}}]}
{ "_id":ObjectId("54bea67c44ae36e60e584d46"),"orgName":"org name","towns":[{"_id":ObjectId("54bd7829104d630153f66082"),"status":"SUBMITTED","contact":{"name":"con name","email":"con@email.com","phone":"34567890123"}}]}
The below queries return null. I expect it to return all the documents.
db.sp.find({'towns.id':{$in:['54bd7829104d630153f66082']}})
db.sp.find({'towns.id':{$in:[ObjectId("54bd7829104d630153f66082")]}})
The below query returns all the three documents
db.sp.find({'towns.status':{$in:['SUBMITTED']}})
asked 32 secs ago
spring query embedded document of arrays
Aucun commentaire:
Enregistrer un commentaire