I have the following collection from which I want to find only documents with a certain label:
{'_id': ObjectId('5f872944677379aa96761ae1'),
'name': 'test',
'labels': ['test1']},
{'_id': ObjectId('5f872944677379aa96761ae2'),
'name': 'test',
'labels': ['test1', 'test2']},
{'_id': ObjectId('5f872944677379aa96761ae3'),
'name': 'test',
'labels': ['test2']},
e.g. - I want to get all the docs with 'test2' in labels
Tried to understand from this answer, but since that case is using dicts and not lists as the embedded element, I can't make it work
The following mongodb example was very useful - but I need to somehow use a wildcard index, like ?
or #
db.inventory.find( { 'instock.0.qty': { $lte: 20 } } )
I used it like
col.find( { 'labels.0': 'test1' } )