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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -