I have table of item list (like image). Now I wanna find a object that have name contain searchString.
I tried query like db.getCollection('vehicles').find({'result': {'name': 'A-WING FIGHTER'}}) but it look wrong.
How can I get true data in this case?
3 Answers
by this
db.getCollection('vehicles').find({ 'result': { 'name': 'A-WING FIGHTER' } })
you are searching for an exact match, so result must be an object with property name only
you should use the dot notation instead
db.getCollection('vehicles').find({ 'results.name': 'A-WING FIGHTER' })
hope it helps
Comments
See if the following command works -
db.getCollection('vehicles').find({'results': {'name': 'A-WING FIGHTER'}})
You named result instead of results. Try if it works now...
You can also try using the following code snippet -
db.getCollection('vehicles').find({ results.name: 'A-WING FIGHTER' });
1 Comment
Abhishek Bhagate
Also,
db.getCollection('vehicles').find({'results': 'A-WING FIGHTER'}) should also work as well if I am not mistaken.