我的datamodel.prisma
如下所示:
type Group {
id: ID!
name: String!
postcodes: [Int!]!
}
我已经生成了一个prisma客户端,然后按如下所示调用createGroup()
:
await prisma.createGroup({ name: group.name, postcodes: [1, 2] });
我遇到错误
{ Error: Variable '$data' expected value of type 'GroupCreateInput!' but got: {"name":"Albury","postcodes":[1,2]}. Reason: 'postcodes' Expected 'GroupCreatepostcodesInput',
found not an object. (line 1, column 11):
有什么主意如何在方尖碑中插入Int
的数组?
答案 0 :(得分:1)
对于数组,Prisma希望您使用set
:
await prisma.createGroup({ name: group.name, postcodes: { set: [1, 2] } });