Answers for "mongodb $or for array items"

1

mongodb $or for array items

// Documents
[{
	...,
  	id: "doc1",
    tags: ["tag 1", "tag 2"]
}]

// Find documents which match all input tags
const inputTags = ["tag 1", "tag 2"]
const results = await Collection.find({
	tags: {
    	$all: inputTags
    }
})

// Find documents which include at least one tag from input tags
const results = await Collection.find({
	tags: {
    	$in: inputTags
    }
})
Posted by: Guest on September-13-2021

Code answers related to "mongodb $or for array items"

Code answers related to "Javascript"

Browse Popular Code Answers by Language