Articles → MONGODB → $Or And $Nor Logical Operators In MongoDB$Or And $Nor Logical Operators In MongoDBIn this article, we will discuss the $or and $nor logical operators in MongoDB.$Or The $or operator performs a logical OR operation on two or more expressions and selects documents that satisfy at least one of the expressions.$Or Example Consider the following collection: -We require to get the list of documents with product in A or B. So, the query will be: -db.sales.find({$or:[{product:'A'}, {product:'B'}]})The output of the above query will be: -$Nor The $nor operator performs a logical NOR operation on two or more expressions and selects documents that satisfy at least one of the expressions.$Nor Example In the above example, if the above query is changed according to the $nor operator then the query will be: -db.sales.find({$nor:[{product:'A'}, {product:'B'}]})Posted By - Karan Gupta Posted On - Thursday, February 15, 2024 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
db.sales.find({$or:[{product:'A'}, {product:'B'}]})
db.sales.find({$nor:[{product:'A'}, {product:'B'}]})
Query/Feedback