"स्टूडेंटफर्स्टनाम" फ़ील्ड नाम के साथ MongoDB में सभी दस्तावेज़ों को खोजने के लिए उपरोक्त सिंटैक्स को लागू करें। क्वेरी इस प्रकार है -
> db.getCollectionNames().forEach(function(myCollectionName) {
... var frequency = db[myCollectionName].find({"StudentFirstName": {$exists: true}}).count();
... if (frequency > 0) {
... print(myCollectionName);
... }
... }); यह निम्नलिखित आउटपुट उत्पन्न करेगा -
multiDimensionalArrayProjection removeKeyFieldsDemo stringOrIntegerQueryDemo
आइए हम सत्यापित करें कि removeKeyFieldsDemo संग्रह में "StudentFirstName" नाम का फ़ील्ड है या नहीं। निम्नलिखित प्रश्न है -
> db.removeKeyFieldsDemo.find({"StudentFirstName":{$exists:true}}); यह निम्नलिखित आउटपुट का उत्पादन करेगा जो StudentFirstName फ़ील्ड को प्रदर्शित करता है -
{ "_id" : ObjectId("5cc6c8289cb58ca2b005e672"), "StudentFirstName" : "John", "StudentLastName" : "Doe" }
{ "_id" : ObjectId("5cc6c8359cb58ca2b005e673"), "StudentFirstName" : "John", "StudentLastName" : "Smith" }