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
Post a Comment