I have a collection called Farms
This is a document from farms:
{
"_id" : ObjectId("513c7db4c079dc17dc75fc26"),
"ownerId" : "J8MpsWChPQdET6jwQ",
"seeds" : [
{
"_id" : ObjectId("513c7db4c079dc17dc75fc26"),
"count" : 1
},
{
"_id" : ObjectId("513c7db4c079dc11dc75fc26"),
"count" : 1
},
{
"_id" : ObjectId("5b5867e081702f675304230f"),
"count" : 5
}
]
}
I want to get seeds arrays object by its id.For example return:
{
"_id" : ObjectId("513c7db4c079dc17dc75fc26"),
"count" : 1
}
This is what i tried:
Farms.find({"ownerId": userid,"seeds._id":seedId},{"seeds._id":1,"seeds.count":1})
returns all document