← All tutorials

GoCareerGo Tutorials

MongoDB Tutorial

Documents, collections, CRUD, aggregation, Atlas and driver connectivity.

$in and $nin

Matching a field against a list of possible values.

Quick-reference summary — a full handcrafted walkthrough is coming soon for this topic.

Matching a field against a list of possible values.

  • Category: MongoDB Operators — part of the MongoDB Tutorial on GoCareerGo
  • Read the short summary above, then check the linked docs for full syntax/behaviour
  • Interview tip: be ready to explain "$in and $nin" in one sentence, then back it up with a tiny example
// $in and $nin — minimal example
// db.collection.<operation>(...)
Tip

Quick recall: "$in and $nin" — matching a field against a list of possible values.