admin 管理员组文章数量: 1184232
Prisma 忽略了我传递给它的值
我正在使用 prisma 处理我的数据库。 这是我的约会表的架构:
model Appointment{
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
date DateTime @db.DateTime()
room String @db.VarChar(45)
observations String @db.VarChar(255)
deleted Boolean @default(false)
doctor Medico @relation(fields: [doctorId], references: [id])
doctorId String
pacient Utente @relation(fields: [pacientId], references: [id])
pacientId String
}
这是我创建约会的方法(我使用 dayjs 将日期作为 YYYY-MM-DD 传递,而不是作为 prisma 的默认格式):
const add = (
date: string,
room: string,
observations: string,
pacientId: string,
doctorId: string
) =>
prisma.appointment.create({
data: {
date: dayjs(date, "YYYY-MM-DD").toDate(),
room,
observations,
pacient: {
connect: {
id: pacientId,
},
},
doctor: {
connect: { id: doctorId },
},
},
include: {
pacient: { select: { name: true } },
doctor: { select: { name: true, specialty: true } },
},
});
我正在使用 Insmomnia 来提出我的要求,这就是我要传递的:
{
"doctorId": "056d3771-07f3-4c5f-9c09-880989597787",
"pacientId": "221056c6-7075-4ae3-acdc-59c85935d6e5",
"date": "2024-05-02",
"room": "E42555",
"observations": "eat before arriving"
}
如您所见,我正在 2024-05-02 创建约会,但我得到的结果是:
{
"id": "250cd42c-2056-429b-908d-4c6e6a707e8f",
"createdAt": "2023-05-07T19:25:42.712Z",
"updatedAt": "2023-05-07T19:25:42.712Z",
"date": "2023-05-07T19:25:43.000Z",
"room": "E42555",
"observations": "eat before arriving",
"deleted": false,
"doctorId": "056d3771-07f3-4c5f-9c09-880989597787",
"pacientId": "221056c6-7075-4ae3-acdc-59c85935d6e5",
"pacient": {
"name": "Adele"
},
"doctor": {
"name": "Joe",
"specialty": "general"
}
}
所以它返回当前日期和时间,而不是我之前通过的日期。 有什么想法吗?
回答如下:本文标签: Prisma 忽略了我传递给它的值
版权声明:本文标题:Prisma 忽略了我传递给它的值 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.roclinux.cn/b/1717595787a709365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论