$nor
定義
例
$nor
Query with Two Expressions
Consider the following query which uses only the $nor
operator:
db.inventory.find( { $nor: [ { price: 1.99 }, { sale: true } ] } )
This query will return all documents that:
contain the
price
field whose value is ではない equal to1.99
and contain thesale
field whose value is not equal totrue
orcontain the
price
field whose value is ではない equal to1.99
but do ではない contain thesale
field ordo ではない contain the
price
field but contain thesale
field whose value is not equal totrue
ordo ではない contain the
price
field and do ではない contain thesale
field
$nor
and Additional Comparisons
次のクエリを考えてみましょう。
db.inventory.find( { $nor: [ { price: 1.99 }, { qty: { $lt: 20 } }, { sale: true } ] } )
This query will select all documents in the inventory
collection
where:
the
price
field value does ではない equal1.99
andthe
qty
field value is ではない less than20
andthe
sale
field value is ではない 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.
$nor
と$exists
Compare that with the following query which uses the
$nor
operator with the $exists
operator:
db.inventory.find( { $nor: [ { price: 1.99 }, { price: { $exists: false } }, { sale: true }, { sale: { $exists: false } } ] } )
This query will return all documents that:
contain the
price
field whose value is ではない equal to1.99
and contain thesale
field whose value is not equal totrue
以下も参照してください。