【发布时间】:2021-05-23 00:25:15
【问题描述】:
也许这是一个非常愚蠢的问题,但是在更新插入时我应该如何将值推送到数组字段?我试图搜索它,但在他们的文档中找不到它。
这是我的架构:
model Chat {
id Int @default(autoincrement()) @id
type Service[]
chatId String @unique
}
这是我试图用来更新数组以向其推送项目的代码:
const chatDb = await prisma.chat.upsert({
where: {
chatId: String(ctx.chat.id),
},
create: {
chatId: String(ctx.chat.id),
type: { set: ['GRAYSCALE'] },
},
update: {
type: { set: ['GRAYSCALE'] },
},
});
我现在的使用方式是用type 数组替换['GRAYSCALE'] 数组。我想将 GRAYSCALE 项推送到数组中,而不是替换它。
我应该如何进行?
【问题讨论】: