MongoDB conditional operator

Source: Internet
Author: User

Tag:nbsp    operator    pre   post   size    rap   f12   div   space   

MongoDB commonly used condition operators have   $LT less than $gt greater than $lte less than or equal to $gte greater than or equal to $ne is not equal to $in in the judge is used to determine whether the element is inside the array $nin not in the judging element is not within the array $or or Judge &N Bsp; > Db.tianyc02.find () {"_id": ObjectId ("50ea6eba12729d90ce6e3423"), "name": "Xttt", "Age": 111} {"_id": O Bjectid ("50ea6eba12729d90ce6e3424"), "name": "Xttt", "Age": 222} {"_id": ObjectId ("50ea6b6f12729d90ce6e341b"), "name" : "Xtt", "Age":} {"_id": ObjectId ("50ea6b7312729d90ce6e341c"), "name": "Xtt", "Age":}> Db.tianyc02.find ({a ge:{$lt: +}}) {"_id": ObjectId ("50ea6b6f12729d90ce6e341b"), "name": "Xtt", "Age":} {"_id": ObjectId ("50ea6b731272 9d90ce6e341c ")," name ":" Xtt "," Age ":}> db.tianyc02.find ({age:{$lt: +, $gt:}}) {" _id ": ObjectId (" 50ea6b731272 9d90ce6e341c ")," name ":" Xtt "," Age ":}> db.tianyc02.find ({age:{$ne: one}}) {" _id ": ObjectId (" 50ea6eba12729d90ce6e 3423 ")," name ":" Xttt "," Age ": 111} {" _id ": ObjectId (" 50ea6eba12729d90ce6e3424 ")," name ":" Xttt "," Age ": 222} {" _id ": ObjectId (" 50ea6b7312729d90ce6e341c ")," name ":" Xtt "," Age ":} 2.2 $in & $nin  > db.tianyc02.find () {" _id ": ObjectId (" 50ea6e ba12729d90ce6e3423 ")," name ":" Xttt "," Age ": 111} {" _id ": ObjectId (" 50ea6eba12729d90ce6e3424 ")," name ":" Xttt "," Age " : 222} {"_id": ObjectId ("50ea6b6f12729d90ce6e341b"), "name": "Xtt", "Age":} {"_id": ObjectId ("50EA6B7312729D90CE 6e341c ")," name ":" Xtt "," Age ":}> db.tianyc02.find ({age:{$in: [11,22]}}) {" _id ": ObjectId (" 50ea6b6f12729d90ce6e3 41b ")," name ":" Xtt "," Age ":} {" _id ": ObjectId (" 50ea6b7312729d90ce6e341c ")," name ":" Xtt "," Age ":}> Db.tia Nyc02.find ({age:{$nin: [11,22]}}) {"_id": ObjectId ("50ea6eba12729d90ce6e3423"), "name": "Xttt", "Age": 111} {"_id": Ob Jectid ("50ea6eba12729d90ce6e3424"), "name": "Xttt", "Age": 222} 2.3 $or  > db.tianyc02.find ({$or: [{The Age : 11},{age:22}]}) {"_id": ObjectId ("50ea6b6f12729d90ce6e341b"), "name": "Xtt", "Age":} {"_id": ObjectId ("50ea6b7312 729d90ce6e341c ")," name ":" XTT "," Age ":}> db.tianyc02.find ({$or: [{age:11},{name: ' Xttt '}]}) {" _id ": ObjectId (" 50ea6eba12729d90ce6e3423 ")," Name ":" Xttt "," Age ": 111} {" _id ": ObjectId (" 50ea6eba12729d90ce6e3424 ")," name ":" Xttt "," Age ": 222} {" _id ": objec TId ("50ea6b6f12729d90ce6e341b"), "name": "Xtt", "Age": 11}

MongoDB conditional operator

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.