I'm quite new to mongodb and there is one thing I can't solve right now:
Let's pretend, you have the following document (simplified):
{
'someKey': 'someValue',
'array' : [
{'name' : 'test1',
'value': 'value1'
},
{'name' : 'test2',
'value': 'value2'
}
]
}
Which query would return the json-object, in which the value equals 'value2'?
That means, i need this json-object:
{
'name' : 'test2',
'value': 'value2'
}
Of course I already tried a lot of possible queries, but none of them returned the right, e.g.
db.test.find({'array.value':'value2'})
db.test.find({'array.value':'value2'}, {'array.value':1})
db.test.find({'array.value':'value2'}, {'array.value':'value2'})
Can someone help and show me, what I'm doing wrong?
Thanks!