$nor¶
On this page
-
$nor¶ $norperforms a logicalNORoperation on an array of one or more query expression and selects the documents that fail all the query expressions in the array. The$norhas the following syntax:
Examples¶
$nor Query with Two Expressions¶
Consider the following query which uses only the $nor operator:
This query will return all documents that:
- contain the
pricefield whose value is not equal to1.99and contain thesalefield whose value is not equal totrueor - contain the
pricefield whose value is not equal to1.99but do not contain thesalefield or - do not contain the
pricefield but contain thesalefield whose value is not equal totrueor - do not contain the
pricefield and do not contain thesalefield
$nor and Additional Comparisons¶
Consider the following query:
This query will select all documents in the inventory collection
where:
- the
pricefield value does not equal1.99and - the
qtyfield value is not less than20and - the
salefield value is not equal totrue
including those documents that do not contain these field(s).
The exception in returning documents that do not contain the field
in the $nor expression is when the $nor operator is
used with the $exists operator.