$nor (Logical NOR)

Last updated: 2026-10-09

$nor (Logical NOR)

$nor combines predicates; a document matches only when none of them hold. `{ $nor: [ { price: 1.99 }, { sale: true } ] }` matches products that are neither $1.99 nor on sale — the inverse of $or. Pitfall: a missing field fails each condition, so $nor silently includes documents missing the fields.

CategoryLogical
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

{ $nor: [ { <condition1> }, { <condition2> }, ... ] }

⚙️ Parameters

conditions arrayAn array of query predicates; none of them may hold.

Returns:Cursor of matching documents

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// $nor: price is not 1.99 and not on sale
db.products.find({
  $nor: [
    { price: 1.99 },
    { sale: true }
  ]
})

Output:

// Returns products neither $1.99 nor on sale; note documents missing the sale field also match

📌 Notes

📚 Related Tutorials

❓ FAQ

QWhat is the difference between $nor and $not?
A$nor requires none of several predicates to hold; $not negates one operator expression.
QWhy does $nor return documents missing the field?
AA missing field satisfies no condition, and $nor requires none to hold — so those documents are included.
QCan $nor nest $or?
AYes, each element inside $nor can be a complex predicate.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏