In this post I am going to explain how to Specify AND Conditions from Mongo DB collection . for this as a sample data you have to upload data into mongo db database.
Implicitly, a logical AND conjunction connects the clauses of a compound query so that the query selects the documents in the collection that match all the conditions.
Thank You !!!
db.inventory.insertMany([
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);
A compound query can specify conditions for more than one field in the collection’s documents.
Implicitly, a logical AND conjunction connects the clauses of a compound query so that the query selects the documents in the collection that match all the conditions.
Then you can execute below query.
db.inventory.find( { status: "A", qty: { $lt: 30 } } )Above selection command is identical to
SELECT * FROM inventory WHERE status = 'A' AND qty < 30;in the SQL
Thank You !!!
Mongo DB :- Specify AND Conditions
Reviewed by Pubudu Dewagama
on
5:05:00 PM
Rating:
If you're trying to lose pounds then you have to jump on this brand new custom keto plan.
ReplyDeleteTo create this keto diet, licenced nutritionists, fitness trainers, and chefs have united to provide keto meal plans that are powerful, convenient, price-efficient, and fun.
From their grand opening in January 2019, thousands of people have already transformed their figure and well-being with the benefits a proper keto plan can provide.
Speaking of benefits; clicking this link, you'll discover 8 scientifically-confirmed ones provided by the keto plan.