Reputation: 83
I have such structure in my Mongo db:
{'_id':'...',
'friends':
{'id1': {'name1':'value1', 'name2':'value2'},
'id2': {'name1':'', 'name2':''},
...}
}
How can I find element(friend) in this dictionary(friends) by name1(value1)?
Upvotes: 8
Views: 18243
Reputation: 4423
If I'm understanding your question correctly You can do this by:
Here is a great resource to start learning mongo and various commands from it.
Upvotes: -2
Reputation: 24078
Is this what you mean?
db.dbname.find({name1:'value1'})
If value1
can be in any field, you can try:
db.dbname.find({$or:[{name1:'value1'},{name2:'value1'}]})
Upvotes: 0