आइए हम दस्तावेजों के साथ एक संग्रह बनाते हैं -
> db.demo362.insertOne({"ClientName":"John","ClientProject":"School Management System"}); { "acknowledged" : true, "insertedId" : ObjectId("5e56a77454a481fef8ec7a1c") } > db.demo362.insertOne({"ClientName":"David","ClientProject":"Library Management System"}); { "acknowledged" : true, "insertedId" : ObjectId("5e56a78454a481fef8ec7a1d") } > db.demo362.insertOne({"ClientName":"Mike","ClientProject":"Event Tracker"}); { "acknowledged" : true, "insertedId" : ObjectId("5e56a7a054a481fef8ec7a1e") } > db.demo362.insertOne({"ClientName":"Carol","ClientProject":"Hospital Management System"}); { "acknowledged" : true, "insertedId" : ObjectId("5e56a7b754a481fef8ec7a1f") }
संग्रह से सभी दस्तावेज़ों को खोजने () विधि की सहायता से प्रदर्शित करें -
> db.demo362.find();
यह निम्नलिखित आउटपुट देगा -
{ "_id" : ObjectId("5e56a77454a481fef8ec7a1c"), "ClientName" : "John", "ClientProject" : "School Management System" } { "_id" : ObjectId("5e56a78454a481fef8ec7a1d"), "ClientName" : "David", "ClientProject" : "Library Management System" } { "_id" : ObjectId("5e56a7a054a481fef8ec7a1e"), "ClientName" : "Mike", "ClientProject" : "Event Tracker" } { "_id" : ObjectId("5e56a7b754a481fef8ec7a1f"), "ClientName" : "Carol", "ClientProject" : "Hospital Management System" }
एकाधिक दस्तावेज़ प्राप्त करने के लिए निम्नलिखित क्वेरी है -
> db.demo362.find({$or: [{"ClientName":"John"}, {"ClientProject": "Event Tracker" }]});
यह निम्नलिखित आउटपुट देगा -
{ "_id" : ObjectId("5e56a77454a481fef8ec7a1c"), "ClientName" : "John", "ClientProject" : "School Management System" } { "_id" : ObjectId("5e56a7a054a481fef8ec7a1e"), "ClientName" : "Mike", "ClientProject" : "Event Tracker" }