Updates are done by calling any of the update operations on a query object
If a document matching the query doesn’t exist, create one
Update multiple documents. The Mongo default is to only update the first matching document
Mark the query as a “safe” query with pymongo.
Parameters: | safe – Defaults to True. Force “safe” on or off |
---|
Usage is either:
set(self, qfield, value): Atomically set qfield to value
OR
set(key1=value1, key2=value2): Atomically set the named arguments on the current object to the values given. This form cannot update a sub-document
Atomically delete the field qfield .. note:: Requires server version >= 1.3.0+.
Atomically increment qfield by value
Atomically append value to qfield. The operation will if the field is not a list field
Atomically append each value in value to the field qfield
Atomically remove value from qfield
Atomically remove each value in value from qfield
Atomically add value to qfield. The field represented by qfield must be a set
Note
Requires server version 1.3.0+.
Atomically pop the last item in qfield. .. note:: Requires version 1.1+
Atomically pop the first item in qfield. .. note:: Requires version 1.1+
Execute the update expression on the database
Remove queries are executed with the remove_query method on a session. They have the same filtering methods as querying.
Execute a remove query to remove the matched objects from the database
Parameters: |
|
---|
Set this remove to be safe. It will call getLastError after the remove to make sure it was successful. **kwargs are parameters to MongoDB’s getLastError command (as in pymongo’s remove).
Run the remove command on the session. Return the result of getLastError if safe is True
Filter the remove expression with *query_expressions, as in the Query filter method.
Filter for the names in filters being equal to the associated values. Cannot be used for sub-objects since keys must be strings
Works the same as the query expression method or_
Works the same as the query expression method in_
Works the same as the query expression method nin_
Find and modify is done by calling find_and_modify on a query object
Execute the find and modify expression on the database
Atomically add value to qfield. The field represented by qfield must be a set
Note
Requires server version 1.3.0+.
Atomically append value to qfield. The operation will if the field is not a list field
Atomically append each value in value to the field qfield
Atomically increment qfield by value
Update multiple documents. The Mongo default is to only update the first matching document
Atomically pop the first item in qfield. .. note:: Requires version 1.1+
Atomically pop the last item in qfield. .. note:: Requires version 1.1+
Atomically remove value from qfield
Atomically remove each value in value from qfield
Mark the query as a “safe” query with pymongo.
Parameters: | safe – Defaults to True. Force “safe” on or off |
---|
Usage is either:
set(self, qfield, value): Atomically set qfield to value
OR
set(key1=value1, key2=value2): Atomically set the named arguments on the current object to the values given. This form cannot update a sub-document
Atomically delete the field qfield .. note:: Requires server version >= 1.3.0+.
If a document matching the query doesn’t exist, create one