হ্যাঁ, MongoDB সহজেই একটি শূন্য মান সূচক করতে পারে। আসুন প্রথমে নথি-
সহ একটি সংগ্রহ তৈরি করি> db.demo170.createIndex({"Value":1},{unique:true});
{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.demo170.insert({"Value":100});
WriteResult({ "nInserted" : 1 })
> db.demo170.insert({"Value":null});
WriteResult({ "nInserted" : 1 })
> db.demo170.insert({"Value":90});
WriteResult({ "nInserted" : 1 })
> db.demo170.insert({"Value":78});
WriteResult({ "nInserted" : 1 }) Find() পদ্ধতি -
এর সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন> db.demo170.find();
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e369b789e4f06af551997da"), "Value" : 100 }
{ "_id" : ObjectId("5e369b7c9e4f06af551997db"), "Value" : null }
{ "_id" : ObjectId("5e369b809e4f06af551997dc"), "Value" : 90 }
{ "_id" : ObjectId("5e369b969e4f06af551997dd"), "Value" : 78 } নিম্নে সূচী শূন্য করার জন্য ক্যোয়ারী −
> db.demo170.find().sort({Value:1}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{ "_id" : ObjectId("5e369b7c9e4f06af551997db"), "Value" : null }
{ "_id" : ObjectId("5e369b969e4f06af551997dd"), "Value" : 78 }
{ "_id" : ObjectId("5e369b809e4f06af551997dc"), "Value" : 90 }
{ "_id" : ObjectId("5e369b789e4f06af551997da"), "Value" : 100 }