var args = new Findandmodifyargs { query=query.gte ("X", 2),//x field is greater than or equal to 2 of the value update=update.inc ("X", 2),//will find the value plus 2 versionreturned=findandmodifydocumentversion.original//Returns the value before the update }; Update the document to modify the x=2 document to x=4. var result=collection. Findandmodify (args); Gets the value before the update. Console.WriteLine (Result. modifieddocument["X"]. ASINT32);
Imongoquery
Query.all ("name","a","b");//to match an array with multiple elementsQuery.and (Query.eq ("name","a"), Query.eq ("title","T"));//satisfy multiple conditions at the same timeQuery.eq ("name","a");//equalsQuery.exists ("type",true);//determine if a key value existsQUERY.GT ("value",2);//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 valuesQUERY.LT ("value",9);//less than <Query.lte ("value",8);//less than or equal to <=Query.mod ("value",3,1);//divides the query value by the first given value and returns the result if the remainder equals the second given valueQuery.ne ("name","C");//Not equal toQuery.nor (Array);//do not include values in the arrayQuery.not ("name");//element Condition StatementQuery.notin ("name","a",2);//returns a document that does not match all the conditions in the arrayQuery.or (Query.eq ("name","a"), Query.eq ("title","T"));//meet one of the conditionsQuery.size ("name",2);//the length of the given keyQuery.type ("_id", Bsontype.objectid);//the type of the given keyQuery.where (Bsonjavascript);//Execute JavaScriptQuery.matches ("Title", str);//fuzzy queries are equivalent to like in SQL--STR can contain regular expressions
MongoDB C # Memo