Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to have a field be auto set every time the model is modified? #50

Open
Thermatix opened this issue Apr 18, 2024 · 1 comment
Open

Comments

@Thermatix
Copy link

I can have a field for setting the creation date:

#[ormlite(default_value = "chrono::Utc::now()")]
pub updated_at: Option<DateTime<Utc>>,

but how can I have a field that is auto set every time the model is modified, I.e. an updated_at field?

@kurtbuilds
Copy link
Owner

The library doesn't support this yet.

I think db triggers is the right approach, so that the update logic isn't dependent on the ORM.

PR is welcome, and happy to answer any questions that come up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants