Mutation rewrites
This section describes the SDL declarations pertaining to mutation rewrites.
Example
Declare two mutation rewrites: one that sets a created
property when a new
object is inserted and one that sets a modified
property on each update:
Copy
type User {
created: datetime {
rewrite insert using (datetime_of_statement());
}
modified: datetime {
rewrite update using (datetime_of_statement());
}
};
Syntax
Define a new mutation rewrite corresponding to the more explicit DDL commands.
rewrite {insert | update} [, ...]
using expr
Mutation rewrites must be defined inside a property or link block.
Description
This declaration defines a new trigger with the following options:
- insert | update [, ...]
-
The query type (or types) the rewrite runs on. Separate multiple values with commas to invoke the same rewrite for multiple types of queries.
- expr
-
The expression to be evaluated to produce the new value of the property.