DQL
EVICT FROM your_collection_name
WHERE [condition]

In this syntax:

  • your_collection_name is the name of the collection from which you want to retrieve the data.
  • [condition] represents the condition or criteria that determine which documents should be evicted from the local peer.

Examples Deleting Documents

Here, documents from the cars collection that have the document ID 123 get removed from the Ditto store:

DQL
EVICT FROM cars
WHERE _id = '123'

As another example, the following snippet, once executed, results in the deletion of documents with timestamps greater than a certain value:

DQL
EVICT FROM cars
WHERE some_time_stamp > 1699888298000

Removing Fields from Documents

To remove a specific field from a document, use an UPDATE statement to tombstone that field. A tombstone is a flag signaling to remote peers that the data type has been removed. See: UPDATE

Removing Data from Big Peer

EVICT can be enabled for Big Peer by request. Please contact us if you’d like to use this feature.

Note that any data evicted from Big Peer will reappear if it exists in any Small Peer devices connected to Big Peer.

To permanently remove the data, you must first ensure the data is no longer subscribed to, and is already evicted, by any connected Small Peers. See Developing an Eviction Strategy for more.

Alternatively, data can be tombstoned from Big Peer using the legacy API. See: Writing: HTTP (Legacy).

Developing an Eviction Strategy

Removing data from a distributed database is a difficult problem, and memory management requires careful consideration of both subscriptions and evictions.

To learn more about our recommended strategies, see DELETE.