Several methods of MongoDB Query

Source: Internet
Author: User
Tags mongodb query

Query. All ("name", "A", "B"); // matches an array with multiple elements.
Query. And (query. eq ("name", "A"), query. eq ("title", "T"); // satisfy multiple conditions at the same time
Query. eq ("name", "A"); // equal
Query. exists ("type", true); // checks whether the key value exists.
Query. gt ("value", 2); // greater than>
Query. GTE ("value", 3); // greater than or equal to> =
Query. In ("name", "A", "B"); // includes all specified values. You can specify different types of conditions and values.
Query. LT ("value", 9); // less than <
Query. Lte ("value", 8); // less than or equal to <=
Query. Mod ("value", 3, 1); // divide the query value by the first given value. If the remainder is equal to the second given value, this result is returned.
Query. Ne ("name", "C"); // not equal
Query. Nor (array); // does not include values in the array
Query. Not ("name"); // element Condition Statement
Query. notin ("name", "A", 2); // returns a document that does not match all the conditions in the array.
Query. Or (query. eq ("name", "A"), query. eq ("title", "T"); // meets one of the conditions
Query. Size ("name", 2); // specify the length of the key.
Query. Type ("_ id", bsontype. objectid); // type of the given key
Query. Where (bsonjavascript); // execute JavaScript
Query. Matches ("title", STR); // fuzzy query is equivalent to like -- STR in SQL that can contain regular expressions.

 

 

 

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.