@focus21/prisma-utils
v1.1.1
Published
Utils for working with Prisma.
Downloads
35
Readme
@focus21/prisma-utils
Utils for working with Prisma.
Installation
pnpm add --save @focus21/prisma-utils
Usage
updateToCreateQuery
Change a Prisma update
query to a create
query.
Useful in upsert
statements.
import { updateToCreateQuery } from "@focus21/prisma-utils";
const myQuery = (update) =>
prisma.table.upsert({
update,
create: updateToCreateQuery(update),
});
createTransaction
Create a transaction if not already in a transaction.
Works as a drop-in replacement for prisma.$transaction
.
import { createTransaction } from "@focus21/prisma-utils";
// Supports an optional transaction
const myQuery = (txOrPrisma = prisma, txOptions = {}) =>
createTransaction(txOrPrisma, (tx) => tx.table.findMany(), txOptions);