সাবডেটা পৌঁছানোর জন্য, আপনাকে MongoDB-তে কী ব্যবহার করতে হবে। আসুন আমরা নথি-
সহ একটি সংগ্রহ তৈরি করি>db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Chris","StudentAge":21}}}); {
"acknowledged" : true,
"insertedId" : ObjectId("5e7b590e71f552a0ebb0a6e6")
}
>db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"David","StudentAge":23}}});{
"acknowledged" : true,
"insertedId" : ObjectId("5e7b591a71f552a0ebb0a6e7")
}
>db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Mike","StudentAge":22}}});{
"acknowledged" : true,
"insertedId" : ObjectId("5e7b592271f552a0ebb0a6e8")
} Find() পদ্ধতি -
এর সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন> db.demo450.find();
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e7b590e71f552a0ebb0a6e6"), "Information" : { "StudentDetails" : {
"StudentName" : "Chris", "StudentAge" : 21 } } }
{ "_id" : ObjectId("5e7b591a71f552a0ebb0a6e7"), "Information" : { "StudentDetails" : {
"StudentName" : "David", "StudentAge" : 23 } } }
{ "_id" : ObjectId("5e7b592271f552a0ebb0a6e8"), "Information" : { "StudentDetails" : {
"StudentName" : "Mike", "StudentAge" : 22 } } } MongoDB −
-এ সাবডেটা পৌঁছানোর জন্য নিম্নোক্ত ক্যোয়ারী> db.demo450.find({"Information.StudentDetails.StudentName":"David"}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e7b591a71f552a0ebb0a6e7"), "Information" : { "StudentDetails" : {
"StudentName" : "David", "StudentAge" : 23 } } }