mongodb - How to filters arrays in Mongo -


i have 1 post property:

ingredients: ['onions', 'carrots'] 

i'm finding post $in adding 1 of these ingredients.

but need find 'onions' or/and 'carrots'. if 'onion' and/or 'carrot' doesn't work.

how this?

if want check both values exist in array, use $all operator:

{ ingredients: { $all: ['onions', 'carrots'] }} 

if want check value use $in operator:

{ ingredients: { $in: ['onions', 'carrots'] }} 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -