Matching values in an array using $nor operator
In this example, we are retrieving only those employee’s documents that does not match the given array.
db.contributor.find({$nor: [{language: {$ in : [ "Java" , "C++" ]}}]}).pretty() |
MongoDB NOR operator ( $nor )
MongoDB provides different types of logical query operators and $nor
operator is one of them. This operator is used to perform logical NOR operation on the array of one or more expressions and select or retrieve only those documents that do not match all the given expression in the array. You can use this operator in methods like find(), update(), etc. according to your requirements.
Syntax:
{ $nor: [ { Expression1 }, { Expression2 }, ... { ExpressionN } ] }
In the following examples, we are working with:
Database: w3wiki
Collection: contributor
Document: three documents that contain the details of the contributors in the form of field-value pairs.
Contact Us