You are currently browsing legacy 1.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Delete Triggers

Delete triggers implement the AbstractDeleteTrigger interface and follow much the same pattern as PUT triggers.

Figure 1: Triggers - Delete

Example: Cascading deletes

public class CascadeDeleteTrigger : AbstractDeleteTrigger

    public override void OnDelete(string key, TransactionInformation txInfo)
        var document = Database.Get(key, txInfo);
        if (document == null)
        Database.Delete(document.Metadata.Value<string>("Cascade-Delete"), null, txInfo);

In this case, we perform another delete operation as part of the current delete operation. This operation is done under the same transaction as the original operation.