Reputation: 51
How would I query the the followoing: get the value of id '120154' for document '123' (result should be 32')
Collection Name:'Collection'
{
"_id" : "123",
"Data" : {
"_v" : [
[
120154,
32
],
[
120156,
"0.940515536000"
],
[
120157,
ISODate("2013-12-26T00:00:00Z")
],
[
120158,
"ABX-HE-AA 06-1"
],
[
120159,
"0A08AG9A4"
]
]}}
Upvotes: 0
Views: 79
Reputation: 1351
I had the same problem and so far I'm unable to find the solution because mongodb queries always return a whole document but you can project fields but that won't return you 32. So when you query {_id : 123} AND {no matter what else}, It will return you the matching whole documents not inner arrays.and I might be wrong but that's what I've experienced
Upvotes: 1
Reputation: 1196
db.collection.find({"_id" : "123"},{"Data._v.$1" : {"$in" : {120154}}})
. I think this should work when u know the _id for the document.
Upvotes: 1