【发布时间】:2021-11-20 15:44:27
【问题描述】:
我一直在向数组推送更新,想知道是否有内置方法也可以从数组中删除条目。基本上颠倒了 push 命令。我怀疑我必须自己查询所有文档并删除该项目。但也许有一些我在文档中找不到的功能。
推送:
const addTag = await prisma.post.update({
where: {
id: 9,
},
data: {
tags: {
push: 'computing',
},
},
})
消除期望:
const removeTag = await prisma.post.update({
where: {
id: 9,
},
data: {
tags: {
splice: 'computing',
},
},
})
【问题讨论】: