Dark Mode

Deleting data

Prerequisites

A mutation can be turned into a delete operation by starting the mutationname with delete or remove .A mutation will also be a delete operation if it is annotated with `@cql_delete`.The mutation must take a single argument that is an input type for a mapped entity,or individual primary key arguments like retrieving operations.If successful, the mutation will return a Boolean value.

At runtime, all partition key fields must be present, and a prefix of theclustering columns can be present (if using a single object argument, other fields will be ignored).The delete operation targets a single row if it operates on a full primary key,or multiple rows otherwise.

Let's add another book "Pride and Prejudice" with an `insertBook()`, so that you can deletethe book using `deleteBook()` to illustrate deleting data:

To check for the existence of a record before deleting, use either method discussed above.This example shows the use of the directive `@cql_delete( ifExists: true)`:

  • 1