I have an array with tags which is part of a document, eg ["red", "green", "blue", "white", "black"]
Now I want to find all documents, which have red AND blue.
I have an array with tags which is part of a document, eg ["red", "green", "blue", "white", "black"]
Now I want to find all documents, which have red AND blue.
Use the $all condition to find records that match both "red" and "blue" conditions.
db.my_collection.find({tags: { $all : ["red","blue"]}})
If you want records that match either "red" or "blue" then you can use the $in condition.
db.my_collection.find({tags: { $in : ["red","blue"]}})