$in
noun
say it: “DOL-er IN” /ˈdɑlər ˈɪn/
A MongoDB filter operator that matches a field whose value is any one of a list of values.
What does $in do in a MongoDB filter?
$in matches documents whose field equals any one of the values in a list, so one filter can ask for several values at once. On an array field, it matches when any item is in the list.
db.recipes.find({ cuisine: { $in: ["Thai", "Japanese", "Korean"] } });
// every Thai, Japanese or Korean recipe
In a sentence
- “$in with an empty list matches nothing at all.”
- “The menu filter used $in to show Thai, Japanese and Korean recipes in one query.”
Level: Apprentice · More MongoDB terms at this level
Updated