Some common query methods of MongoDB

  • 2020-05-17 06:52:05
  • OfStack


Query.All("name", "a", "b");// An array is matched by multiple elements 
Query.And(Query.EQ("name", "a"), Query.EQ("title", "t"));// Multiple conditions are satisfied at the same time 
Query.EQ("name", "a");// Is equal to the 
Query.Exists("type", true);// Determine whether the key value exists 
Query.GT("value", 2);// Is greater than >
Query.GTE("value", 3);// Greater than or equal to >=
Query.In("name", "a", "b");// Includes all values specified , 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 order 1 A given value , If the remainder is equal to th 2 Three given values return the result 
Query.NE("name", "c");// Is not equal to 
Query.Nor(Array);// Does not include the values in the array 
Query.Not("name");// Element conditional statement 
Query.NotIn("name", "a", 2);// Returns a document that does not match any of the conditions in the array 
Query.Or(Query.EQ("name", "a"), Query.EQ("title", "t"));// To meet the 1 A condition 
Query.Size("name", 2);// Given the length of the key 
Query.Type("_id", BsonType.ObjectId);// The type of the given key 
Query.Where(BsonJavaScript);// perform JavaScript
Query.Matches("Title", str);// Fuzzy query   The equivalent of sql In the like -- str You can include regular expressions 


Related articles: