prisma-extension-streams
v1.0.15
Published
Prisma Streams is a typescript first module that will transform SQL data from queries in streams, in order to improve performance in larger datasets. This module will be configured as a [Prisma ORM](https://www.prisma.io) [client extension](https://www.pr
Downloads
19
Maintainers
Readme
NPM Module for Streams in Prisma ORM
Prisma Streams is a typescript first module that will transform SQL data from queries in streams, in order to improve performance in larger datasets. This module will be configured as a Prisma ORM client extension that will return Node Streams from Prisma queries.
It's recomendable to take a look on Prisma install and configuration before using this module.
Quick start
To use extension:
Create your prisma client in project (if doesnt exists) using:
npx prisma generate
Install Prisma Streams.
npm install prisma-extension-streams
Import Prisma Streams module inside your project
import { PrismaStreams } from 'prisma-extension-streams'; //OR import * as PrismaStreams from 'prisma-extension-streams';
Set $extends configuration and create a new Prisma Client, example:
import { PrismaStreams } from 'prisma-extension-streams'; const prismaClient = new PrismaClient() const xprisma = prismaClient.$extends(PrismaStreams) //OR const prismaClient = new PrismaClient().$extends(PrismaStreams)
Usage example:
import { PrismaStreams } from 'prisma-extension-streams'; const prismaClient = new PrismaClient().$extends(PrismaStreams) async findAll() { //TS Ignore is necessary because this is a beta feature on Prisma and type-safety is being improved. //@ts-ignore const stream = prismaClient.product.findManyStream() for await (const entity of stream) { console.log(entity.id) }
} ```
GitHub
If you liked this project, dont hesitate to star that project on our GitHub. Happy Code c: