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 Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

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