Skip to content

Logical Operators

  1. $and
```sh
shop> db.products.find({$and: [{price: {$lt: 3150}}, {'name': 'Diamond Ring'}]})

It is same as

shop> db.products.find({price: {$lt: 3150}}, {'name': 'Diamond Ring'})

Because when we use multiple query operations in find method, then MongoDB treats them as implict AND operations.

2. $or
```sh
shop> db.products.find({$or: [{price: {$lt: 1150}}, {'name': 'Diamond Ring'}]})
  1. $not
shop> db.products.find({price: {$not: {$eq: 500}}})
  1. $nor
shop> db.products.find({$nor: [{price: {$lt: 1150}}, {'name': 'Diamond Ring'}]})