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

4.0.0 • 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

2,255

Version

4.0.0

License

Apache-2.0

Unpacked Size

41.9 kB

Total Files

36

Last publish

Collaborators

  • bodrovis
  • marcocardosolok
  • laurislokalise
  • botlokalise
  • kibertoad
  • carlos_gamero
  • aplokalise
  • filippos.mikropoulos
  • arthuracs
  • andrew_lokalise
  • dariacm
  • forter_lokalise
  • mmounirf
  • mattfinucane
  • bezlydmitry
  • frei_ondrej_lokalise