MongoDB সংগ্রহের জন্য _ দিয়ে শুরু হয়, নিম্নলিখিত সিনট্যাক্স −
db.createCollection(‘_yourCollectionName’);
নিচের সিনট্যাক্স −
ব্যবহার করে ক্যোয়ারী ঢোকানdb.getCollection('_yourCollectionName').insertOne({"yourFieldName1":"yourValue1","yourFieldName2":yourValue2,............N}); আসুন প্রথমে নথি-
সহ একটি সংগ্রহ তৈরি করি> db.createCollection('_testUnderscoreCollectionDemo');
{ "ok" : 1 }
>db.getCollection('_testUnderscoreCollectionDemo').insertOne({"StudentFirstName":"John","StudentAge":23});
{
"acknowledged" : true,
"insertedId" : ObjectId("5ccfb4a6140b992277dae0e4")
}
>db.getCollection('_testUnderscoreCollectionDemo').insertOne({"StudentFirstName":"Carol","StudentAge":21});
{
"acknowledged" : true,
"insertedId" : ObjectId("5ccfb4af140b992277dae0e5")
} Find() পদ্ধতির সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করার জন্য নিম্নলিখিত প্রশ্ন রয়েছে -
> db.getCollection('_testUnderscoreCollectionDemo').find().pretty(); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{
"_id" : ObjectId("5ccfb4a6140b992277dae0e4"),
"StudentFirstName" : "John",
"StudentAge" : 23
}
{
"_id" : ObjectId("5ccfb4af140b992277dae0e5"),
"StudentFirstName" : "Carol",
"StudentAge" : 21
}