在棱镜中的Int上插入数组

时间:2019-02-25 03:39:48

标签: arrays insert prisma

我的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的数组?

1 个答案:

答案 0 :(得分:1)

对于数组,Prisma希望您使用set

await prisma.createGroup({ name: group.name, postcodes: { set: [1, 2] } });