MongoDB Query Operators In Hindi | MongoDB Operators With Example

📔 : MongoDB 🔗

तो अभी तक आपने MongoDB का basic concept समझा , जैसे जिसमे आपने collection को create करना , documents को insert , update और delete करना सीखा।

हालाँकि ये सिर्फ basic need थी MongoDB को अच्छी तरह से समझने के लिए क्योंकि development में सिर्फ इतने से काम नहीं चलेगा। Most important आपको filtering और query बनानी तो सीखनी पड़ेगी।

क्योंकि जैसा कि आप जानते ही है कि MongoDB semi-structured या unstructured database system है। ऐसे में query builder काफी important है ताकि आप अच्छे से collections को manage कर पाए।

Understanding MongoDB Operators In Hindi

MongoDB में query operators का use documents को query करने और filter करने के लिए होता है। ये operators specific conditions को define करने में use किये जाते हैं , जो भी user की need होती है।

नीचे कुछ common लेकिन important MongoDB query operators दिखाए गए हैं।

MongoDB Comparison Operators

Comparison operators वहां use होते हैं जहाँ पर हम दो values के बीच comparison करते हैं , ये ठीक उसी तरह से जैसे programming languages like : Java , PHP , Python , JavaScript , C , C++ में होते हैं।

  • $eq : Equals operator, document field की value को specified value से match करता है।

  • $ne : Not Equals operator , match करता है कि document field की value specified value के equal नहीं है।

  • $gt : Greater Than operator check करता है कि document field की value specified value से बड़ी है।

  • $lt : Less Than operator , check करता है document field की value specified value से छोटी है।

  • $gte : Greater Than or Equal To, operator check करता है document field की value specified value से बड़ी या equal है।

  • $lte : Less Than or Equal To, operator check करता है document field की value specified value से छोटी या equal है।

MongoDB Logical Operators

Logical Operators , एक या एक से अधिक expression पर apply होते हैं। हालाँकि या पर भी comparison ही होता है।

  • $and : documents fetch होंगे जहाँ सभी queries match होगी।

  • $or : documents fetch होंगे अगर दी गयी queries में से कोई एक match होती है।

  • $nor : documents return होंगे अगर दोनों ही conditions match नहीं होती।

  • $not : documents return होंगे जब query match नहीं होती है।

MongoDB Array Operators

Document में हम किसी Array को as a value भी रख सकते हैं , जिसके लिए specially कुछ operators हैं।

  • $in : Document field में specified values में से कोई भी value match हो।

  • $nin : Document field में specified values में से कोई भी value न हो।

  • $all : Document field मेब specified values के सभी elements match हैं।

  • $elemMatch : Array के अंदर sub andar sub-document (Object) के लिए specific conditions को match करने के लिए।

  • $size : Array field का size check करने के लिए।

Other

  • $regex : Regular expression का use करके text field को filter किया जाता है।

  • $text : इसका use Text search queries के लिए किया जाता है।

  • $near : एक specified point के नजदीक के documents को filter करना।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers