Consider the following sample document
[{
"Name" : "John doe",
"age" : 22,
"email" : "john@doe.com"
},
{
"Name" : "William",
"age" : 28,
"email" : "william@william.com"
},
{
"Name" : "jack",
"age" : 22,
"email" : "jack@jack.com"
}]
I have an array of objects with me with the following structure
[{'name':'jack','age':10},{'name':'john','age':20}]
How do I perform a query in the document in a way such that I can match the name field and age field of my array of objects of each element. Basically, the name jack
and the age 10
should query with the sample and after that the name john
and the age 20
should perform the query.
I know that $elemMatch
could have been used if it was the other way around where I had to query with single elements in an array. Is there any way of doing this?
via puneeth8994
No comments:
Post a Comment