To remove a document from an Edge SDK device without permanently deleting it see
EVICT.When using
DELETE ensure that devices running Ditto Edge SDK are on version 4.10.1 and later.For more information on how to use delete and manage data reach out to Ditto’s Customer SupportWhen using
DELETE on Edge SDKs-Only deployments reach out to Ditto’s Customer Support to ensure the
best design patterns are being used to avoid data loss and/or performance related issues.DELETE operation permanently removes one or more documents from a Ditto collection. Once a document is
deleted it cannot be recovered. Deleted documents can be re-created by using the INSERT operation with
the same document id as the deleted document.
Syntax
DQL
your_collection_nameis the name of the collection from which you want to retrieve the data.[ids]represents the document IDs to delete, given as a parameter or a literal list, rather than selecting documents with aWHEREpredicate (optional).[condition]represents the condition or criteria that determine which documents should be evicted from the local peer.[order by]represents the path within a document to use to order the dataset and order (ASCorDESC).[limit]represents the maximum number of documents that should be evicted.[offset]represents the offset from 0 that should be used for the eviction query, in practice this should be rarely used.[projection]returns fields or expressions taken from the deleted documents (optional). See RETURNING.
Examples of Deleting Documents
Here, the document with ID123 is permanently removed from the cars collection:
DQL
DQL
Deleting Documents by ID
The optionalUSE IDS clause names the documents to delete by ID, instead of selecting them with a WHERE predicate. The IDs may be supplied as a literal list or as a query parameter:
DQL
DELETE with RETURNING
Add aRETURNING clause to get back the deleted documents, as they were immediately before removal, rather than just the IDs of the documents that were deleted:
DQL
RETURNING is the only way to recover their contents. For the full projection rules, aggregate support and the restrictions that apply, see RETURNING.
Using DQL to Delete Documents in the Edge SDK
For specifics on deleting documents Ditto SDKs seeSDK>CRUD>Removing Documents.
TOMBSTONE Keyword
TheTOMBSTONE keyword (currently Ditto Server only) is a synonym for the new DELETE keyword. Users using the TOMBSTONE keyword will get the auto
cleanup properties of DELETE without any changes. TOMBSTONE will be deprecated/removed in an upcoming Major release.
Removing Fields from Documents
TheDELETE keyword is used to remove documents from a collection. To remove a
specific field from a document see Update > Deleting
Fields.
Removing a Collection
DQL does not provide aDROP COLLECTION statement, and the portal does not expose an action to delete a collection directly. Deleting every document in a collection is not equivalent to dropping it — the collection itself continues to exist after its documents are removed.
To empty a collection of its documents, run:
DQL
store.execute.