Reputation: 27763
This operation finds all uploads that have tags "important" OR "school":
db.uploads.find({tags: {$in: ['important', 'school']}})
What I want do is show only uploads that have tags "important" AND "school." Is this the only way?
db.uploads.find({$and: [{tags: 'important'}, {tags: 'school'}]})
Upvotes: 1
Views: 45
Reputation: 2092
You need to use $all
operator:
db.uploads.find( { tags: { $all: [ "important", "school"] } } )
Upvotes: 2