gpt4 book ai didi

prisma - Prisma 中带有时区列的时间戳

转载 作者:行者123 更新时间:2023-12-04 13:11:39 52 4
gpt4 key购买 nike

我正在评估 Prisma,我是一个完整的菜鸟......

  • 我正在使用 Postgresql
  • 我有以下模型定义
  • model Sth {
    id Int @default(autoincrement()) @id
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
    expiresAt DateTime?
    }
    createdAt列转换为 createdAt | timestamp(3) without time zone | | not null | CURRENT_TIMESTAMP由于我打算真正使用时间戳 - 我需要它们是 timestamp with time zone .
    如何使用 Prisma 实现这一目标?
    立即编辑()> '2021-02-16' : Prisma 现在有“原生类型”
  • https://github.com/prisma/prisma/releases/tag/2.17.0
  • https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#postgresql-6
  • 最佳答案

    目前timestamptz字段不受支持,因为 Prisma 会自动将您发送的时间戳转换为 UTC。该支持将通过 this 在更高版本的 Prisma 中提供。要求。
    作为一种解决方法,您需要将时间戳转换为特定的所需时区,因为 Prisma 会将其以 UTC 格式保存在数据库中。

    关于prisma - Prisma 中带有时区列的时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64535044/

    52 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com