কম্পিউটার

মঙ্গোডিবি কোয়েরি "কোথায়" বিলিং ঠিকানাটি নথি থেকে ডেলিভারি ঠিকানার সমান?


সমতা পরীক্ষা করতে এবং নথিগুলি আনতে, MongoDB-এ $where ব্যবহার করুন৷ আসুন নথি-

সহ একটি সংগ্রহ তৈরি করি
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"UK"});{
   "acknowledged" : true, "insertedId" : ObjectId("5e92c117fd2d90c177b5bccc")
}
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"US"});{
   "acknowledged" : true, "insertedId" : ObjectId("5e92c11bfd2d90c177b5bccd")
}
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"AUS"});{
   "acknowledged" : true, "insertedId" : ObjectId("5e92c11ffd2d90c177b5bcce")
}
> db.demo589.insertOne({deliveryAddress:"UK",billingAddress:"US"});{
   "acknowledged" : true, "insertedId" : ObjectId("5e92c127fd2d90c177b5bccf")
}

Find() পদ্ধতি -

এর সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন
> db.demo589.find();

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
{ "_id" : ObjectId("5e92c117fd2d90c177b5bccc"), "deliveryAddress" : "US", "billingAddress" : "UK" }
{ "_id" : ObjectId("5e92c11bfd2d90c177b5bccd"), "deliveryAddress" : "US", "billingAddress" : "US" }
{ "_id" : ObjectId("5e92c11ffd2d90c177b5bcce"), "deliveryAddress" : "US", "billingAddress" : "AUS" }
{ "_id" : ObjectId("5e92c127fd2d90c177b5bccf"), "deliveryAddress" : "UK", "billingAddress" : "US" }

এখানে "কোথায়" বিলিং ঠিকানাটি ডেলিভারি ঠিকানার সমান তা পরীক্ষা করার জন্য এবং নথিগুলি আনার জন্য প্রশ্ন রয়েছে -

> db.demo589.find( { $where: "this.deliveryAddress == this.billingAddress" } );

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
{ "_id" : ObjectId("5e92c11bfd2d90c177b5bccd"), "deliveryAddress" : "US", "billingAddress" : "US" }

  1. ডুপ্লিকেট নথি গোষ্ঠীতে MongoDB ক্যোয়ারী

  2. MongoDB ক্যোয়ারী মান সহ একটি অ্যারে দেওয়া মিলিত নথি খুঁজে পেতে?

  3. নির্দিষ্ট FirstName এবং LastName সহ নথিগুলি খুঁজতে MongoDB ক্যোয়ারী

  4. MongoDB - এমবেডেড নথি জিজ্ঞাসা করবেন?