Mongo DB :- Specify Equality Condition

In this post I am going to explain how to Specify Equality Condition from Mongo DB collection . for this as a sample data you have to upload data into mongo db database.

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" }
]);



To specify equality conditions,  use <field>:<value> expressions in the query filter document:

Then you can execute below query.
db.inventory.find({ status: "D"}) 
Above selection command is identical to
SELECT * FROM inventory WHERE status = 'D';
 in the SQL


Thank You !!!

Mongo DB :- Specify Equality Condition Mongo DB :- Specify Equality Condition Reviewed by Pubudu Dewagama on 4:19:00 PM Rating: 5

1 comment:

  1. If you're trying hard to lose weight then you have to start following this totally brand new tailor-made keto meal plan.

    To create this service, licensed nutritionists, personal trainers, and professional cooks have united to develop keto meal plans that are effective, convenient, economically-efficient, and delightful.

    Since their grand opening in January 2019, 1000's of clients have already remodeled their figure and health with the benefits a good keto meal plan can offer.

    Speaking of benefits: in this link, you'll discover 8 scientifically-confirmed ones provided by the keto meal plan.

    ReplyDelete