system.mongodb.deleteOne
New in 8.1.28
This function is used in Python Scripting.
note
Project Library scripts will not provide hints for MongoDB system functions unless the Script Hint Scope is set to Gateway. See the Scripting in Ignition page for more details on scripting hints.
Description
Removes a document from the collection that matches the filter.
Client Permission Restrictions
This scripting function has no Client Permission restrictions.
Syntax
system.mongodb.deleteOne(connector, collection, filter, [options])
Parameters
| Type | Parameter | Description |
|---|---|---|
| String | connector | The name of connector (case-insensitive). |
| String | collection | The name of collection (case-sensitive). |
| PyDictionary | filter | A PyDictionary for specifying matching key value pair criteria when querying a collection. |
| PyDictionary | options | A PyDictionary for including additional delete configurations. [optional] |
Returns
PyDictionary result - Result of delete action formatted as a PyDictionary with keys ‘acknowledged’ and ‘deleteCount’.
Scope
Gateway, Perspective Session
Code Examples
Example #1
# Import required BSON types.
from system.mongodb.types import ObjectId
# Specify unique field values to locate specific document. Here we are specifying the known _id of the document.
filter = {"_id": ObjectId("63fe3941519feb58abb3cda1")}
# Apply parameters for function call.
print system.mongodb.deleteOne("MongoDB", "customers", filter)