$ne¶
-
$ne¶ Syntax:
{field: {$ne: value} }$neselects the documents where the value of thefieldis not equal (i.e.!=) to the specifiedvalue. This includes documents that do not contain thefield.Consider the following example:
This query will select all documents in the
inventorycollection where theqtyfield value does not equal20, including those documents that do not contain theqtyfield.Consider the following example which uses the
$neoperator with a field in an embedded document:This
update()operation will set theqtyfield value in the documents that contain the embedded documentcarrierwhosestatefield value does not equal “NY”, or where thestatefield or thecarrierembedded document do not exist.