Reputation: 923
I have a nested document like this -
"name" : "Naman",
"gender" : "M",
"occupation" : {
"company" : "Honda",
"designation" : "manager",
"salary" : "1000000",
}
How do I write a query in morphia that gives me all those people with company, say : "Honda" and post "manager"
Upvotes: 0
Views: 560
Reputation: 1164
Try this
db.yourcollection.find({'occupation.company':'Honda','occupation.designation':'manager'})
use Dot notation of mongoDB to get values from nested array/document
Upvotes: 1