आइए दस्तावेजों के साथ एक संग्रह बनाएं -
> db.demo711.insertOne({Name:"John",,"Marks":75,Age:21,status:"Active"});{ "acknowledgeed" :true, "insertId" :ObjectId("5ea85c215d33e20ed1097b7e ")}> db.demo711.insertOne({Name:"Chris",,"Marks":55,Age:22,status:"Active"});{ "स्वीकृत" :सच, "insertId" :ObjectId("5ea85c2c5d33e20ed1097b7f ")}> db.demo711.insertOne({Name:"Bob",,"Marks":45,Age:20,status:"Inactive"});{ "स्वीकृत" :सच, "insertId" :ObjectId("5ea85c3e5d33e20ed1097b80 ")}> db.demo711.insertOne({Name:"David",,"Marks":85,Age:23,status:"Active"});{ "स्वीकृत" :सच, "insertId" :ObjectId("5ea85c775d33e20ed1097b81 ")}
संग्रह से सभी दस्तावेज़ों को खोजने () विधि की सहायता से प्रदर्शित करें -
> db.demo711.find();
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
{ "_id" :ObjectId("5ea85c215d33e20ed1097b7e"), "Name" :"John", "Marks" :75, "Age" :21, "status" :"Active" }{ "_id" :ObjectId( "5ea85c2c5d33e20ed1097b7f"), "नाम" :"क्रिस", "मार्क्स" :55, "आयु" :22, "स्थिति" :"सक्रिय" }{ "_id" :ObjectId ("5ea85c3e5d33e20ed1097b80"), "नाम" :" बॉब", "चिह्न" :45, "आयु" :20, "स्थिति" :"निष्क्रिय" }{ "_id" :ObjectId ("5ea85c775d33e20ed1097b81"), "नाम" :"डेविड", "मार्क्स" :85, " आयु" :23, "स्थिति" :"सक्रिय" }
$या −
. के साथ MongoDB क्वेरी निम्नलिखित है> db.demo711.find( { $या:[ {आयु:{$gte:23}}, {चिह्न:{$gt:80} }, {स्थिति:'निष्क्रिय'} ] });पूर्व>यह निम्नलिखित आउटपुट उत्पन्न करेगा -
{ "_id" :ObjectId("5ea85c3e5d33e20ed1097b80"), "Name" :"Bob", "Marks" :45, "Age" :20, "status" :"Inactive" }{ "_id" :ObjectId( "5ea85c775d33e20ed1097b81"), "नाम" :"डेविड", "मार्क्स" :85, "आयु" :23, "स्थिति" :"सक्रिय" }