Is it possible to use something like 'exists' in a Mongo query to return this record based on an ID?
Something like select where 'ids' contains key '123456'?
{
"department": "Digging",
"ids": {
"123456": {
"color": "blue"
},
"123457": {
"color": "red"
}
}
}
As you're searching for the existence of a field with a given name, $exists is the operator you need (see Advanced Queries).
e.g. something like:
db.YourCollection.find({ "ids.123456" : {$exists: true}});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With