DeleteEntity ============ Deletes entity objects that satisfy the specified constraints. All connections associated with the objects will also be deleted. Parameters ---------- ``ref`` and ``constraints`` are optional and are intersected when both are present. ``with_class`` further narrows the selection. **Scope warning:** omitting all selectors targets every object in public entity classes. Always supply selectors for a scoped mutation. .. list-table:: :header-rows: 1 :widths: 15 25 60 * - Parameter - JSON type - Behavior * - :ref:`constraints ` - array expression - Optional. No property filter; the command-specific selector requirement still applies. Filters existing objects using the constraints expression language. When ref is supplied it filters that referenced set. * - :ref:`ref ` - integer, 1 through 100000 - Optional. Select using the other supplied selectors; see the selection rule above. Uses an earlier compatible Entity reference in this transaction; forward references, wrong types, and undeclared references are rejected. * - :ref:`with_class ` - nonempty string, not starting with underscore - Optional. No additional class restriction; without a reference, all public classes are eligible. Restricts the mutation to this entity class, including when ref is supplied. Details ------- .. include:: delete_details.rst Response and errors ------------------- An authenticated session with the objects delete permission is required. The response is an object under ``DeleteEntity`` with integer ``status`` and, on success, integer ``count``. Status 0 means the mutation completed; count is the number of selected objects affected, including zero when none match. No output blobs are returned. Invalid field types, missing required fields, malformed expressions, and invalid references fail validation. Execution failures include a nonzero status and an ``info`` message; inspect the transaction response before assuming a mutation succeeded. Deleting nodes also removes incident connections. Examples -------- Delete entities of class "Animal" whose "species" property equals "Mammal": .. TESTED_EXAMPLE: DeleteEntity_1 .. code-block:: json [{ "DeleteEntity": { "with_class": "Animal", "constraints": ["$species", "==", "Mammal"] } }] Successful response: .. TESTED_EXAMPLE: DeleteEntity_1_response .. code-block:: json [{ "DeleteEntity": { "status": 0, "count": 1 } }] Delete entities of the class "Patient" with "firstname" property equal to "Bob" and connected to entities of class "Visit" with "billing_id" value set to 125: .. TESTED_EXAMPLE: DeleteEntity_2 .. code-block:: json [{ "FindEntity": { "_ref": 1, "with_class": "Visit", "constraints": ["$billing_id", "==", 125] } }, { "FindEntity": { "_ref": 2, "with_class": "Patient", "constraints": ["$firstname", "==", "Bob"], "is_connected_to": { "ref": 1 } } }, { "DeleteEntity": { "ref": 2 } }] Successful response: .. TESTED_EXAMPLE: DeleteEntity_2_response .. code-block:: json [{ "FindEntity": { "returned": 0, "status": 0 } }, { "FindEntity": { "returned": 0, "status": 0 } }, { "DeleteEntity": { "status": 0, "count": 1 } }]