Reputation: 33
I have a collection in which objects looks like:
{
"_id":ObjectId(""),
"payload":{
"roles":[
{
"contract_part":"1111",
"role_key":"",
"party_key":"29-29",
"address_key":null,
"changed_at":"2017-07-18T18:30:00",
"changed_nr":NumberLong(1),
"type":NumberLong(33),
"contract_key":"999",
"business_to":"2999-01-01T00:00:00",
"business_from":"2017-07-18T18:30:00"
}
]
},
"id":NumberLong("10345"),
"event":"role.created",
"aggregate":"role",
"timestamp":"2017-07-18T21:30:00.000+03:00"
}
And I struggle with creating a db.collection.find()
that will allow me to find the object with specific "role_key"
.
Upvotes: 3
Views: 36
Reputation: 1416
Try using this
db.collection.find({"payload.roles": {$elemMatch: {role_key:" "}}})
Upvotes: 1