Are mongodb ids unique ?

MongoDB $and and $or Operators

MongoDb OR ($or) Operator

The $or operator are used to performs a logical OR operation on more than two expressions and returns all the match documents.

Syntax:  {$or: [ { <expression 1> }, { <expression 2> }, .. , { <expression N> } ]}

Query:
db.customers.find({
       "$or": [{ "Age": 30 },
 { "Name": "Anil Singh" }]
});

MongoDb OR ($or) AND AND ($and) Operator

The $and operator are used to performs a logical AND operation on more than two expressions and returns all the match documents.

Syntax:  {$and: [ { <expression 1> }, { <expression 2> } , .. , { <expression N> } ] }

Query:

db.customers.find({
              $and:[
                        {$or:[{"Name" : "Anil Singh"}
                  ]},
                  {"Age": "30"}
]});


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^