Reputation: 11804
My datamodel.prisma
looks like the following:
type Group {
id: ID!
name: String!
postcodes: [Int!]!
}
I have generated a prisma-client, and then calling createGroup()
as follows:
await prisma.createGroup({ name: group.name, postcodes: [1, 2] });
I am getting an error
{ 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):
Any idea how to insert an array of Int
in prisma?
Upvotes: 1
Views: 1906
Reputation: 2471
For an array, Prisma expect you to use set
:
await prisma.createGroup({ name: group.name, postcodes: { set: [1, 2] } });
Upvotes: 2