How would I use `createMany` with a set of data th...
# prisma-client
d
How would I use
createMany
with a set of data that may have duplicates in the db (based on two non-@id fields)
Like, first I may need to figure out how to create a constraint. My schema has
external_id, provider_id
that should be distinct.
r
Hi @David Marr, in your model you can add them as
@@unique[external_id, provider_id]
(I think the syntax is correct)
Like:
Copy code
model User {
  id        Int     @default(autoincrement())
  firstName String
  lastName  String
  isAdmin   Boolean @default(false)

  @@unique([firstName, lastName])
}
https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#unique-1
d
Thanks Richard.