@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

ExportTypePurpose
NestService<T>classCRUD service — _find, _get, _create, _patch, _remove
applyFilters()functionApply parsed filters to Prisma query options
rawQuery()functionConvert a FeathersJS query to a Prisma where
GlobalExceptionFilterfilterMaps PrismaClientKnownRequestError (P2002, P2003, P2025, …) to HTTP

Usage

cats.service.ts
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);
  }
}
Querying
await catsService._find({
  name: { $iLike: 'kitty' },
  age: { $gt: 5 },
  $include: { owner: true },
  $sort: { createdAt: -1 },
  $limit: 10,
});

Relations are eager-loaded with $include (Prisma's include). $iLike is fully case-insensitive on PostgreSQL — see Querying for per-database notes.

Next steps