operations
– Operation class definitions
Operation class definitions.
class pymongo.operations.DeleteMany
(filter, collation=None, hint=None)
Create a DeleteMany instance.
For use with bulk_write().
Parameters: |
|
---|
Changed in version 3.11: Added the hint
option.
Changed in version 3.5: Added the collation option.
class pymongo.operations.DeleteOne
(filter, collation=None, hint=None)
Create a DeleteOne instance.
For use with bulk_write().
Parameters: |
|
---|
Changed in version 3.11: Added the hint
option.
Changed in version 3.5: Added the collation option.
class pymongo.operations.IndexModel
(keys, \*kwargs*)
Create an Index instance.
For use with create_indexes().
Takes either a single key or a list of (key, direction) pairs. The key(s) must be an instance of basestring
(str in python 3), and the direction(s) must be one of (ASCENDING, DESCENDING, GEO2D, GEOHAYSTACK, GEOSPHERE, HASHED, TEXT).
Valid options include, but are not limited to:
- name: custom name to use for this index - if none is given, a name will be generated.
- unique: if
True
, creates a uniqueness constraint on the index.- background: if
True
, this index should be created in the background.- sparse: if
True
, omit from the index any documents that lack the indexed field.- bucketSize: for use with geoHaystack indexes. Number of documents to group together within a certain proximity to a given longitude and latitude.
- min: minimum value for keys in a GEO2D index.
- max: maximum value for keys in a GEO2D index.
- expireAfterSeconds: <int> Used to create an expiring (TTL) collection. MongoDB will automatically delete documents from this collection after <int> seconds. The indexed field must be a UTC datetime or the data will not expire.
- partialFilterExpression: A document that specifies a filter for a partial index. Requires MongoDB >= 3.2.
- collation: An instance of Collation that specifies the collation to use in MongoDB >= 3.4.
- wildcardProjection: Allows users to include or exclude specific field paths from a wildcard index using the { “$**” : 1} key pattern. Requires MongoDB >= 4.2.
- hidden: if
True
, this index will be hidden from the query planner and will not be evaluated as part of query plan selection. Requires MongoDB >= 4.4.
See the MongoDB documentation for a full list of supported options by server version.
Parameters: |
|
---|
Changed in version 3.11: Added the hidden
option.
Changed in version 3.2: Added the partialFilterExpression
option to support partial indexes.
document
An index document suitable for passing to the createIndexes command.
class pymongo.operations.InsertOne
(document)
Create an InsertOne instance.
For use with bulk_write().
Parameters: |
|
---|
class pymongo.operations.ReplaceOne
(filter, replacement, upsert=False, collation=None, hint=None)
Create a ReplaceOne instance.
For use with bulk_write().
Parameters: |
|
---|
Changed in version 3.11: Added the hint
option.
Changed in version 3.5: Added the collation
option.
class pymongo.operations.UpdateMany
(filter, update, upsert=False, collation=None, array_filters=None, hint=None)
Create an UpdateMany instance.
For use with bulk_write().
Parameters: |
|
---|
Changed in version 3.11: Added the hint option.
Changed in version 3.9: Added the ability to accept a pipeline as the update.
Changed in version 3.6: Added the array_filters option.
Changed in version 3.5: Added the collation option.
class pymongo.operations.UpdateOne
(filter, update, upsert=False, collation=None, array_filters=None, hint=None)
Represents an update_one operation.
For use with bulk_write().
Parameters: |
|
---|
Changed in version 3.11: Added the hint option.
Changed in version 3.9: Added the ability to accept a pipeline as the update.
Changed in version 3.6: Added the array_filters option.
Changed in version 3.5: Added the collation option.