এর জন্য, আপনি ডট(.) নোটেশন সহ $ এবং ব্যবহার করতে পারেন। আসুন প্রথমে নথি-
সহ একটি সংগ্রহ তৈরি করি>db.demo2.insertOne({"StudentInformation":[{"StudentName":"John","StudentAge":21},{"StudentName":"Mike","StudentAge":22}]});
{
"acknowledged" : true,
"insertedId" : ObjectId("5e08b56e25ddae1f53b62219")
}
>db.demo2.insertOne({"StudentInformation":[{"StudentName":"Carol","StudentAge":19},{"StudentName":"Bob","StudentAge":18}]});
{
"acknowledged" : true,
"insertedId" : ObjectId("5e08b58625ddae1f53b6221a")
} Find() পদ্ধতির সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করার জন্য নিম্নলিখিত প্রশ্ন রয়েছে -
> db.demo2.find().pretty();
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{
"_id" : ObjectId("5e08b56e25ddae1f53b62219"),
"StudentInformation" : [
{
"StudentName" : "John",
"StudentAge" : 21
},
{
"StudentName" : "Mike",
"StudentAge" : 22
}
]
}
{
"_id" : ObjectId("5e08b58625ddae1f53b6221a"),
"StudentInformation" : [
{
"StudentName" : "Carol",
"StudentAge" : 19
},
{
"StudentName" : "Bob",
"StudentAge" : 18
}
]
} অ্যারে−
-এ নির্দিষ্ট বৈশিষ্ট্য ধারণ করে এমন নথিগুলি পাওয়ার জন্য নিচের ক্যোয়ারী রয়েছে>db.demo2.find({$and:[{"StudentInformation.StudentName":"Carol"},{"StudentInformation.StudentName":"Bob"}]}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e08b58625ddae1f53b6221a"), "StudentInformation" : [ { "StudentName" : "Carol", "StudentAge" : 19 }, { "StudentName" : "Bob", "StudentAge" : 18 } ] }