@nest-extended/prisma
The Prisma adapter: the same generic CRUD service and query language as the other adapters, backed by Prisma for PostgreSQL, MySQL and SQLite.
$npm install @nest-extended/core @nest-extended/prisma @nest-extended/decorators nestjs-cls
Key exports
| Export | Type | Purpose |
|---|---|---|
NestService<T> | class | CRUD service — _find, _get, _create, _patch, _remove |
applyFilters() | function | Apply parsed filters to Prisma query options |
rawQuery() | function | Convert a FeathersJS query to a Prisma where |
GlobalExceptionFilter | filter | Maps PrismaClientKnownRequestError (P2002, P2003, P2025, …) to HTTP |
Usage
import { Injectable } from '@nestjs/common';
import { NestService } from '@nest-extended/prisma';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class CatsService extends NestService<any> {
constructor(private readonly prisma: PrismaService) {
super(prisma.cat);
}
}await catsService._find({
name: { $iLike: 'kitty' },
age: { $gt: 5 },
$include: { owner: true },
$sort: { createdAt: -1 },
$limit: 10,
});Relations are eager-loaded with
$include(Prisma'sinclude).$iLikeis fully case-insensitive on PostgreSQL — see Querying for per-database notes.