is there a way to get an item by id, and if it doe...
# orm-help
g
is there a way to get an item by id, and if it doesn't exist... then create the item
a
Hey there 👋, welcome to the Prisma community, no such thing as a bad question! The Prisma Client doesn’t have a dedicated API for doing a “find or create” operation, but you can achieve it using the `upsert` method and leaving the
update
option blank.
Copy code
const user = await prisma.user.upsert({
  where: { email: '<mailto:alice@prisma.io|alice@prisma.io>' },
  update: {},
  create: { email: '<mailto:alice@prisma.io|alice@prisma.io>' },
})
g
oh... that worked, thanks a lot mate, sorry for the late reply tho