Reputation: 3214
I have such document tructure:
I need to find all documents where 'full' key is equal to '20200518_cbmoAXY.jpeg'
The best query I ended up with is:
db.getCollection('Advert').find({ $where: "this.images && this.images.length && (this.images[0].full == '20200518_cbmoAXY.jpeg')" })
But it finds nothing although record is present.
Upvotes: 0
Views: 49
Reputation: 3214
This is how I solved:
db.getCollection('Advert').find({ 'images.0.full' : '20200518_cbmoAXY.jpeg'})
Upvotes: 1