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

2.0.1 • Public • Published
NPM Discord Apache-2.0

Lamware - Prisma ORM

This Lamware Middleware allows you to initialize and memoize your Prisma Client.

Installation

This package is available via NPM:

yarn add @lamware/prisma

# or

npm install @lamware/prisma

Usage

import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { PrismaClient } from '@prisma/client';
import { prisma } from '@lamware/prisma';
import { lamware } from '@lamware/core';

const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
  // You can provide your PrismaClient directly.
  .use(prisma(PrismaClient))

  // Or an (a)synchronous set-up closure.
  .use(prisma(async () => {
    return new PrismaClient();
  }))

  .execute(async ({ state }) => {
    const user = await state.prisma.user.findUnique({
      where: { id: 1 },
    });

    return { statusCode: 200 };
  });

export { handler };

Package Sidebar

Install

npm i @lamware/prisma

Weekly Downloads

32

Version

2.0.1

License

GPL-3.0-only

Unpacked Size

39.2 kB

Total Files

8

Last publish

Collaborators

  • oyed