@lokalise/prisma-utils
TypeScript icon, indicating that this package has built-in type declarations

3.2.2 • Public • Published

Prisma utils

This package provides reusable helpers for Prisma query builder.

Usage

import { prismaTransaction } from '@lokalise/prisma-utils'

const result: Either<unknown, [Item, Segment]> = await prismaTransaction(prisma, [
	prisma.item.create({ data: TEST_ITEM_1 }),
	prisma.segment.create({ data: TEST_SEGMENT_1 }),
])

This implementation will retry the transaction on P2034 error, which satisfies Prisma recommendations for distributed databases such as CockroachDB.

Prisma metrics plugin

Plugin to collect and send metrics to prometheus. Prisma metrics will be added to our app metrics.

Add the plugin to your Fastify instance by registering it with the following options:

  • isEnabled;
  • collectionOptions (by default we collect metrics every 5 seconds) to override default collector behaviour

Once the plugin has been added to your Fastify instance and loaded, we will start collection prisma metrics.

Readme

Keywords

none

Package Sidebar

Install

npm i @lokalise/prisma-utils

Weekly Downloads

1,231

Version

3.2.2

License

Apache-2.0

Unpacked Size

30.6 kB

Total Files

25

Last publish

Collaborators

  • bodrovis
  • marcocardosolok
  • laurislokalise
  • botlokalise
  • kibertoad
  • carlos_gamero
  • aplokalise
  • filippos.mikropoulos
  • yury.kravtsov
  • arthuracs
  • andrew_lokalise
  • dariacm
  • forter_lokalise
  • mmounirf