Delete statement
You can use operators @
, @?
, @*
, @+
to specify cardinality, like for the at-operator. A run-time error occurs if
the number of deleted records doesn't match the cardinality.
delete user @ { .name == 'Bob' }; // exactly one
delete user @? { .name == 'Bob' }; // zero or one
delete user @* { .company.name == 'Bad Company' }; // any number
Using multiple entities. It's similar to an update
, where you delete only the objects of the first entity:
delete (u: user, c: company) @ { u.xyz == c.xyz, u.name == 'Bob', c.name == 'Google' };
Can specify an arbitrary expression returning an entity, a nullable entity, or a collection of entities:
val u = user @? { .name == 'Bob' };
delete u;