নথি গণনা করতে, $count ব্যবহার করুন। 13 দিয়ে শুরু হওয়া মানগুলির জন্য, $regex ব্যবহার করুন। আপনি $regex ব্যবহার করতে পারেন। আসুন নথি-
সহ একটি সংগ্রহ তৈরি করি> db.demo570.insertOne({Information:{Value:"13675"}});{
"acknowledged" : true, "insertedId" : ObjectId("5e90959b39cfeaaf0b97b583")
}
> db.demo570.insertOne({Information:{Value:"14135"}});{
"acknowledged" : true, "insertedId" : ObjectId("5e9095a739cfeaaf0b97b584")
}
> db.demo570.insertOne({Information:{Value:"15113"}});{
"acknowledged" : true, "insertedId" : ObjectId("5e9095b639cfeaaf0b97b585")
}
> db.demo570.insertOne({Information:{Value:"13141"}});{
"acknowledged" : true, "insertedId" : ObjectId("5e9095c139cfeaaf0b97b586")
} Find() পদ্ধতি -
এর সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন> db.demo570.find();
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e90959b39cfeaaf0b97b583"), "Information" : { "Value" : "13675" } }
{ "_id" : ObjectId("5e9095a739cfeaaf0b97b584"), "Information" : { "Value" : "14135" } }
{ "_id" : ObjectId("5e9095b639cfeaaf0b97b585"), "Information" : { "Value" : "15113" } }
{ "_id" : ObjectId("5e9095c139cfeaaf0b97b586"), "Information" : { "Value" : "13141" } } দ্রুত কর্মক্ষমতার জন্য নিম্নোক্ত ক্যোয়ারী যা একটি সূচক ব্যবহার করবে −
> db.demo570.count({'Information.Value': { '$regex' : '^13' }}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে2