ankushbbbr
ankushbbbr

Reputation: 923

morphia nested document query

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

Answers (1)

Tanay Sharma
Tanay Sharma

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

Related Questions