আসুন প্রথমে নথি-
সহ একটি সংগ্রহ তৈরি করি>db.demo144.insertOne({"EmployeeDetails":[{"EmployeeName":"Chris","EmployeeEmail":"[email protected]"},{"EmployeeName":"Bob","EmployeeEmail":"[email protected]"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5e32f1d8fdf09dd6d08539b9") } >db.demo144.insertOne({"EmployeeDetails":[{"EmployeeName":"David","EmployeeEmail":"[email protected]"},{"EmployeeName":"Carol","EmployeeEmail":"[email protected]"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5e32f1f5fdf09dd6d08539ba") }
Find() পদ্ধতি -
এর সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন> db.demo144.find();
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e32f1d8fdf09dd6d08539b9"), "EmployeeDetails" : [ { "EmployeeName" : "Chris", "EmployeeEmail" : "[email protected]" }, { "EmployeeName" : "Bob", "EmployeeEmail" : "[email protected]" } ] } { "_id" : ObjectId("5e32f1f5fdf09dd6d08539ba"), "EmployeeDetails" : [ { "EmployeeName" : "David", "EmployeeEmail" : "[email protected]" }, { "EmployeeName" : "Carol", "EmployeeEmail" : "[email protected]" } ] }
অবজেক্টের অ্যারের মধ্যে ফলাফল খুঁজে পেতে এবং ইমেল ঠিকানা ফিল্ডের সাথে মেলে -
>db.demo144.find({"EmployeeDetails.EmployeeName":"David","EmployeeDetails.EmployeeEmail":"[email protected]"},{"EmployeeDetails.EmployeeName":1});>
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e32f1f5fdf09dd6d08539ba"), "EmployeeDetails" : [ { "EmployeeName" : "David" }, { "EmployeeName" : "Carol" } ] }