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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.