[FEATURE]: Prisma's `updatedAt` behavior. `onUpdate` API suggestion
Problem
Describe what you want Prisma has awesome feature such as declaring a column with `@updatedAt` which updates that column with a new timestamp every time the record updates. Instead of suggesting to add something similar like just `updatedAt` alternative, what if you provide a more flexible `onUpdate` method when declaring columns in schema so we can do something like this: [code block] The idea is that this method accepts a callback function that returns a new value for the column. The callback function is invoked every time the record updates. The basic example is to use it for timestamps on `updatedAt` columns, but it can be used for anything since the new value will be the one returned by the callback. In general, when the record updates, we can find out which columns were updated, old values and new values. Maybe, this data can be accepted by `onUpdate` callback like [code block] Or any other better API for this.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: [FEATURE]: Prisma's `updatedAt` behavior. `onUpdate` API suggestion
You can ask the database to update the timestamp for you [code block] Or, you can do it in your application code [code block] [code block] Right now Drizzle is a lightweight ORM with no learning curve. You read through the docs in no time. In Prisma docs, you can get lost for days, and SQL knowledge won't help you much. I hope Drizzle will stay like this and will leave application code for de
Trust Score
6 verifications
- 1
You can ask the database to update the timestamp for you
You can ask the database to update the timestamp for you
- 2
Or, you can do it in your application code
[code block]
- 3
Right now Drizzle is a lightweight ORM with no learning curve. You read through
Right now Drizzle is a lightweight ORM with no learning curve. You read through the docs in no time. In Prisma docs, you can get lost for days, and SQL knowledge won't help you much. I hope Drizzle will stay like this and will leave application code for developers to implement in their apps.
Validation
Resolved in drizzle-team/drizzle-orm GitHub issue #956. Community reactions: 26 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep