Query condition usage in MongoDB official C # driver

Source: Internet
Author: User

The basic syntax for MongoDB conditional query.

 

1 query. all ("name", "A", "B"); // matches array 2 3 query with multiple elements. and (query. eq ("name", "A"), query. eq ("title", "T"); // meets multiple conditions at the same time. eq ("name", "A"); // 6 7 query. exists ("type", true); // determines whether the key value exists 8 9 query. GT ("value", 2); // greater than> 10 11 query. GTE ("value", 3); // greater than or equal to> = 12 13 query. in ("name", "A", "B"); // includes all specified values. You can specify different types of conditions and values for 14 15 queries. LT ("value", 9); // less than <16 17 query. LTE ("value", 8); // less than or equal to <= 18 19 query. moD ("value", 3, 1); // divide the query value by the first given value. If the remainder is equal to the second given value, the result 20 21 query is returned. ne ("name", "C"); // not equal to 22 23 query. nor (array); // does not include the value in the array 24 25 query. not ("name"); // element Condition Statement 26 27 query. notin ("name", "A", 2); // returns a query that does not match all the conditions in the array. or (query. eq ("name", "A"), query. eq ("title", "T"); // meets one of the conditions 30 31 query. size ("name", 2); // The length of the given key is 32 33 queries. type ("_ id", bsontype. objectid); // type of the given key 34 35 query. where (bsonjavascript); // execute javascript36 37 query. matches ("title", STR); // fuzzy query is equivalent to like -- STR in SQL that can contain Regular Expressions

 

 

The basic syntax for MongoDB conditional query.

 

1 query. all ("name", "A", "B"); // matches array 2 3 query with multiple elements. and (query. eq ("name", "A"), query. eq ("title", "T"); // meets multiple conditions at the same time. eq ("name", "A"); // 6 7 query. exists ("type", true); // determines whether the key value exists 8 9 query. GT ("value", 2); // greater than> 10 11 query. GTE ("value", 3); // greater than or equal to> = 12 13 query. in ("name", "A", "B"); // includes all specified values. You can specify different types of conditions and values for 14 15 queries. LT ("value", 9); // less than <16 17 query. LTE ("value", 8); // less than or equal to <= 18 19 query. moD ("value", 3, 1); // divide the query value by the first given value. If the remainder is equal to the second given value, the result 20 21 query is returned. ne ("name", "C"); // not equal to 22 23 query. nor (array); // does not include the value in the array 24 25 query. not ("name"); // element Condition Statement 26 27 query. notin ("name", "A", 2); // returns a query that does not match all the conditions in the array. or (query. eq ("name", "A"), query. eq ("title", "T"); // meets one of the conditions 30 31 query. size ("name", 2); // The length of the given key is 32 33 queries. type ("_ id", bsontype. objectid); // type of the given key 34 35 query. where (bsonjavascript); // execute javascript36 37 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.