Light
Dark
System
v4latest
v5dev
v4latest
v3
v2
v1

Mutation rewrites

This section describes the SDL declarations pertaining to mutation rewrites.

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());
  }
};

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.

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.

Light
Dark
System

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.