MongoDB-এ SQL-এর NOT LIKE সমতুল্য অপারেশন করতে $not অপারেটর রেগেক্সের সাথে ব্যবহার করা হয়।
উদাহরণ ডেটা:
> db.notLikeOperatorDemo.insertOne({"StudentName": "John Doe"});
> db.notLikeOperatorDemo.insertOne({"StudentName": "John Smith"});
> db.notLikeOperatorDemo.insertOne({"StudentName": "John Taylor"});
> db.notLikeOperatorDemo.insertOne({"StudentName": "Carol Taylor"});
> db.notLikeOperatorDemo.insertOne({"StudentName": "David Miller"});
"John Taylor"어로 শুরু হয় না এমন নাম খুঁজা (দুটি পদ্ধতি):
> db.notLikeOperatorDemo.find({StudentName: {$not: /^John Taylor.*/}});
> db.notLikeOperatorDemo.find({StudentName: {$not: /John Taylor/}});
ফলাফল (দুটোই একই):
{"_id": ObjectId("..."), "StudentName": "John Doe"}
{"_id": ObjectId("..."), "StudentName": "John Smith"}
{"_id": ObjectId("..."), "StudentName": "Carol Taylor"}
{"_id": ObjectId("..."), "StudentName": "David Miller"}
John Taylor বাদে বাকি সব ফেরত আসে। $not রেগেক্স মാച নেগেট করে। কেস-ইনসেনসিটিভের জন্য /pattern/i ব্যবহার করুন।