Skip to content

Instantly share code, notes, and snippets.

@albertorestifo
Last active October 6, 2021 10:02
Show Gist options
  • Save albertorestifo/6d35d4e5fd492987091ae76557b2c64a to your computer and use it in GitHub Desktop.
Save albertorestifo/6d35d4e5fd492987091ae76557b2c64a to your computer and use it in GitHub Desktop.
Example idempotent creation with Prisma
// Suppose createData includes all the other required fields,
// and idempotencyKey is received as part of the request payload.
await this.prisma.ctrPayrollCompensation.upsert({
where: { idempotencyKey },
create: { ...createData, idepotencyKey },
update: {}, // Update nothing
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment