Last-modified tracking
You need an audit field showing the latest modification time for each row.
Prisma · Const
@updatedAt automatically tracks when a record was last updated. Prisma Client manages the value for DateTime fields when the application does not provide one.
@updatedAt is a Prisma schema attribute for DateTime fields. Prisma Client supplies the current time when you omit a value and updates the field when a record changes, while an update with an empty clause leaves it unchanged.
updatedAt DateTime @updatedAtmodel Post {
id Int @id @default(autoincrement())
updatedAt DateTime @updatedAt
}Define a DateTime field with @updatedAt; Prisma Client fills it automatically and refreshes it when the record is updated.
You need an audit field showing the latest modification time for each row.
Your application should populate update timestamps without repeating timestamp logic in every write.
You want Prisma-managed time values rather than relying on a database timestamp expression.
It automatically stores when a record was last updated. If the application does not provide a time, Prisma Client sets the field automatically.
Follow-up: Where is the behavior implemented? It is implemented in the Prisma ORM layer, not as a database-side operation.
The field must use the DateTime type, and the attribute is placed after that field declaration. A typical declaration is updatedAt DateTime @updatedAt.
Follow-up: Can it be attached to a String field? No; the documentation specifies compatibility with DateTime fields.
A normal update causes Prisma to refresh the timestamp, but an empty update clause leaves the existing value unchanged. This means no-op updates do not necessarily advance the field.
Follow-up: How can database-generated timestamps differ from this value? Database functions such as now() run at the database level, while @updatedAt runs in Prisma ORM.
DateTimenow()@default