-
MongoDB में दो तारीखों के बीच और विशिष्ट मान के साथ डेटा प्राप्त करें। ग्रुप करके योग और गिनती प्राप्त करें?
MongoDB में डेटा फ़िल्टर करने के लिए $match का उपयोग करें और दो तारीखों के बीच डेटा प्राप्त करने के लिए $gte और $lte ऑपरेटर्स का उपयोग करें। आइए एक कलेक्शन बनाते हैं जिसमें डॉक्यूमेंट्स हों: > db.demo560.insertOne({value1:40,value2:40,shippingDate:new ISODate(2020-02-26)}); { acknowledged : true
-
MongoDB में Unique Data Randomize करके EmailID में "John" Prefix Add करना
Unique data randomize करने के लिए MongoDB में Math.random() का उपयोग करें। Collection बनाना > db.demo561.insertOne({EmailId:null}); { acknowledged : true, insertedId : ObjectId(5e8f490454b4472ed3e8e86c) } > db.demo561.insertOne({EmailId:null}); { acknowledged : true, insertedId : ObjectId(5e8
-
MongoDB में किसी रिकॉर्ड (फ़ील्ड) को खोजकर कैसे हटाएं?
MongoDB में $exists से फ़ील्ड खोजें और $unset से हटाएं फ़ील्ड खोजने के लिए $exists और हटाने के लिए $unset का उपयोग करें। MongoDB में $unset ऑपरेटर किसी विशेष फ़ील्ड को हटा देता है। आइए दस्तावेज़ों के साथ एक संग्रह बनाते हैं: > db.demo562.insertOne({Name:Chris,Age:21});{ acknowledged : true, inser
-
MongoDB शेल का उपयोग करके दस्तावेज़ों से विशिष्ट मान वाले आइटम कैसे प्राप्त करें?
MongoDB शेल में find() से विशिष्ट मान वाले दस्तावेज़ फ़िल्टर करें विशिष्ट मान वाले आइटम प्राप्त करने के लिए, बस find() का उपयोग करें। आइए दस्तावेज़ों के साथ एक संग्रह बनाते हैं: > db.demo563.insertOne({Name:Chris,Age:21,isMarried:true}) { acknowledged : true, insertedId : ObjectId(5e8f546c54b4472
-
MongoDB में Single Array Value को String से Replace करना
Replace करने के लिए $set और positional $ operator का उपयोग करें। Collection बनाना > db.demo564.insertOne({StudentName:[Chris,David,Mike,Sam]}); { acknowledged : true, insertedId : ObjectId(5e90880a39cfeaaf0b97b576) } सभी Documents Display करना > db.demo564.find().pretty(); Output: { _id :
-
MongoDB में Document के Fields Access करना
Document में fields access करने के लिए simply find() का उपयोग करें। Collection बनाना > db.demo565.insertOne( ... { ... id:101, ... Name:David, ... CountryName:US ... } ... ); { acknowledged : true, insertedId : ObjectId(5e90896739cfeaaf0b97b577) } > db.demo565.insertOne( ... { ... id:
-
MongoDB में Array Items Group करके Similar Price Products Count करना
Array items group करने के लिए $group के साथ $sort का उपयोग करें। Collection बनाना > db.demo566.insertOne( ... { ... ProductInformation : [ ... { ProductName : Product-1, ProductPrice :100 }, ... { ProductName : Product-2, ProductPrice :1100 }, ... { ProductName : Product-3, Product
-
MongoDB Collection Query - Find() में Some Fields Exclude करना
जिन fields को include नहीं करना उन्हें 0 set करें। यहाँ हमने fields yourFieldName1 और yourFieldName2 को 0 set किया: db.yourCollectionName.find(yourQuery, {yourFieldName1:0,yourFieldName2:0}); Collection बनाना > db.demo567.insertOne({Name:Chris,Age:21}); { acknowledged : true, insertedId : Object
-
MongoDB में ISODate से Month, Day, Year आदि Fetch करना
Mongo shell विभिन्न methods provide करता है जैसे ISODate() date return करने के लिए, either string या Date object के रूप में। ISODate() constructor ISODate() wrapper का उपयोग करके Date object return करता है। Collection बनाना > db.demo548.insertOne({dueDate:new ISODate(2020-04-09 12:12:40)}); { ac
-
MongoDB में Specific Amount के Records Find करना
Specific amount के records find करने के लिए MongoDB में LIMIT() का उपयोग करें। यह method एक number type argument accept करता है, जो display होने वाले documents की संख्या है। Collection बनाना > db.demo549.insertOne({Name:Chris}); { acknowledged : true, insertedId : ObjectId(5e8e32889e5f92834d7f05
-
MongoDB में Bulk Operations से Multiple Updates और Array Elements Update करना
इसके लिए initializeOrderedBulkOp() का उपयोग करें। यह collection के लिए new Bulk() operations builder initialize और return करता है। Builder write operations की ordered list construct करता है जो MongoDB bulk में execute करता है। Collection बनाना >db.demo550.insertOne({Name:Chris,details:[{Marks:49
-
MongoDB में Same Key पर Multiple OR Conditions
इसके लिए simply $or once उपयोग करें। Collection बनाना > db.demo551.insertOne({Name:John}); { acknowledged : true, insertedId : ObjectId(5e8e36d39e5f92834d7f05e5) } > db.demo551.insertOne({Name:Chris Brown}); { acknowledged : true, insertedId : ObjectId(5e8e36d89e5f92834d7f05e6) } > db.demo
-
MongoDB में Average से ऊपर के Values वाले Documents Select करना
MongoDB में average से ऊपर के values वाले documents select करने के लिए aggregate() का उपयोग करें। Average find करने के लिए $avg का उपयोग करें। Collection बनाना > db.demo552.insertOne({values:10}); { acknowledged : true, insertedId : ObjectId(5e8e3b1c9e5f92834d7f05ea) } > db.demo552.insertOne(
-
MongoDB में Document के अंदर Array के अंदर Object Update करने का Syntax
इसके लिए MongoDB में findOneAndUpdate() का उपयोग करें। findOneAndUpdate() method filter और sort criteria के आधार पर single document update करता है। Collection बनाना > db.demo553.insertOne( ... { ... id:101, ... Name:John, ... midExamDetails: ... [ ... {SubjectName:MySQL,Marks:70}, ..
-
MongoDB Query - Name और Email Field पर "Like" Implementation
MongoDB में like implementation के लिए // का उपयोग करें और specific letter को बीच में set करें। उदाहरण: /J/ Collection बनाना > db.demo554.insertOne({UserName:John,UserMailId:John@gmail.com}); { acknowledged : true, insertedId : ObjectId(5e8f1cfed1d72c4545cb8679) } > db.demo554.insertOne({User
-
MongoDB Aggregation Framework - Specific Field Value Match करना
Specific field value match करने के लिए MongoDB aggregation में $match का उपयोग करें। Collection बनाना > db.demo555.insertOne({CountryName:US}); { acknowledged : true, insertedId : ObjectId(5e8f21bf54b4472ed3e8e85f) } > db.demo555.insertOne({CountryName:UK}); { acknowledged : true, insertedId
-
MongoDB में Subdocument Array से Records Fetch करना (ID 234 से शुरू)
Subdocument array से records fetch करने के लिए $unwind के साथ $push का उपयोग करें। IDs जो 234 से शुरू होते हैं, उनके लिए MongoDB में regex का उपयोग करें। Collection बनाना > db.demo556.insertOne( ... { ... _id:101, ... details:[ ... { id:234336, Name:Chris }, ... { id:123456, Name:Bob
-
MongoDB Query - केवल Specific Field Value Update करना
आइए उदाहरण देखते हैं और documents के साथ collection बनाते हैं: Collection बनाना > db.demo557.insertOne({Name:Chris}); { acknowledged : true, insertedId : ObjectId(5e8f28e954b4472ed3e8e864) } > db.demo557.insertOne({Name:David}); { acknowledged : true, insertedId : ObjectId(5e8f28ee54b4472ed3e
-
MongoDB Capped Collection का उपयोग करना
हाँ, आप capped collection उपयोग कर सकते हैं। Capped collections fixed-size collections होते हैं जो high-throughput operations support करते हैं जो insertion order के आधार पर documents insert और retrieve करते हैं। Capped Collection बनाना > db.createCollection(demo539, { capped : true, size :100, m
-
MongoDB में Field द्वारा Documents Group करके Select करना
Field द्वारा documents group करके select करने के लिए $group के साथ $project का उपयोग करें। Collection बनाना > db.demo540.insertOne({id:1,Name:Chris,CountryName:US}); { acknowledged : true, insertedId : ObjectId(5e8ca368ef4dcbee04fbbc0e) } > db.demo540.insertOne({id:1,Name:Chris,CountryName:UK