Prisma sqlite列表
我正在尝试使用 String []
将列表添加到模型中,但是它给了我这个错误:
Field "stats" in model "Player" can't be a list.
The current connector does not support lists of primitive types.
代码:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./db.db"
}
model Player {
id String @id @default(cuid())
stats String[]
}
有办法做到这一点吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另外,您可以尝试使用字符串类型列,然后在写入数据库之前将数组转换为带有commas的字符串。
但是,更新将需要更多的工作,因为您不能使用
unsot
或prisma中的
方法,并且如果您的更新取决于当前状态,则可能必须使用多个查询(例如1st查询以获取当前数组,第二查询以更新数组)。https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#-modifier
Alternatively, you can try using a string type column and convert your array into string with separator like commas before writing into database.
However, update will require more work as you cannot use
unset
orpush
method from prisma, and likely have to use multiple queries if your update depends on the current state (e.g. 1st query to get the current array, 2nd query to update array).