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