我正在评估 Prisma,我是一个十足的菜鸟......
model Sth {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
expiresAt DateTime?
}
Run Code Online (Sandbox Code Playgroud)
该createdAt专栏翻译为
createdAt | timestamp(3) without time zone | | not null | CURRENT_TIMESTAMP
因为我打算真正使用时间戳 - 我需要它们timestamp with time zone。
我如何使用 Prisma 实现这一目标?
编辑 NOW() > '2021-02-16':Prisma 现在具有“本机类型”
Hed*_*ges 28
对于我们这些生活在未来的人来说,现在可以通过 Prisma 的“本机数据库类型属性”为 postgresql 保存带有时间戳和时区的记录。
https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#postgresql-6
请注意,对于我的数据库,我必须将时区设置为'UTC',以便将正确的时区设置为我想要的时区@default。
上面的示例使用了 Native 数据库类型属性。
model Sth {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now()) @db.Timestamptz(3)
updatedAt DateTime @updatedAt @db.Timestamptz(3)
expiresAt DateTime? @db.Timestamptz(3)
}
Run Code Online (Sandbox Code Playgroud)