showing results for - "mongodb 24or for array items"
Alex
20 Sep 2018
1// Documents
2[{
3	...,
4  	id: "doc1",
5    tags: ["tag 1", "tag 2"]
6}]
7
8// Find documents which match all input tags
9const inputTags = ["tag 1", "tag 2"]
10const results = await Collection.find({
11	tags: {
12    	$all: inputTags
13    }
14})
15
16// Find documents which include at least one tag from input tags
17const results = await Collection.find({
18	tags: {
19    	$in: inputTags
20    }
21})