Skip to content

Any change to describe a default source for a property that sets a new value on an update? #3180

Answered by elprans
shackra asked this question in Q&A
Discussion options

You must be logged in to vote

Currently, there isn't a schema-level way of implementing updated_at like you've described, so you'll need to keep including updated_at := std::datetime_current() in your UPDATE statements.

We are working on a general query rewrite system (see roadmap), which would allow arbitrary injection of operations into queries based on a condition (or unconditionally). Here's how (tentatively) your schema would look:

module default {
     abstract type DatedType {
          required property updated_at -> datetime;
          property deleted_at -> datetime;

          rule bump_updated_at on update {
              update DatedType set { updated_at := datetime_current() }
          }
     }
}

Or, i…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@ifiokjr
Comment options

@elprans
Comment options

Answer selected by shackra
Comment options

You must be logged in to vote
1 reply
@raddevon
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants