@nestjs-dash/prisma 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +49 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @nestjs-dash/prisma
2
+
3
+ The Prisma `ResourceAdapter`/`DatabaseAdapter` implementation for nestjs-dash.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @nestjs-dash/prisma
9
+ ```
10
+
11
+ ## No auto-bind helper — by design
12
+
13
+ Unlike `@nestjs-dash/typeorm`/`@nestjs-dash/mikroorm`, there is **no** `bindPrismaResourcesFromModels` auto-bind helper here, deliberately: the Prisma adapter has no dependency on `@prisma/client`'s generated DMMF types, since those types only exist after a *consumer* runs `prisma generate` against their own schema — a library can't depend on types it can't see. Wiring each resource's adapter is a few explicit lines instead.
14
+
15
+ Prisma resources also don't take a `static model` — since there's nothing to decorate on a Prisma model, a resource's properties come from its `table()`'s declared columns, not model introspection.
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { createPrismaResourceFromModel } from '@nestjs-dash/prisma';
21
+ import { AdminModule } from '@nestjs-dash/nestjs';
22
+
23
+ AdminModule.forRootAsync({
24
+ useFactory: (prisma: PrismaService) => {
25
+ AuthorResource.adapter = createPrismaResourceFromModel(AuthorResource, prisma.author);
26
+ BookResource.adapter = createPrismaResourceFromModel(BookResource, prisma.book);
27
+ return { panel: { resources: [AuthorResource, BookResource] } };
28
+ },
29
+ inject: [PrismaService],
30
+ });
31
+ ```
32
+
33
+ ```ts
34
+ export class AuthorResource extends Resource {
35
+ static override slug = 'authors';
36
+ // no `static model` — properties come from `table()` below
37
+ static override table(table: Table) {
38
+ return table.columns([TextColumn.make('id'), TextColumn.make('name').sortable().searchable()]);
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Part of nestjs-dash
44
+
45
+ This package is one piece of [nestjs-dash](https://github.com/nestjs-dash/nestjs-dash), a NestJS-native admin framework. See the `example-prisma` demo app for a complete `Author`/`Book` admin wired against Postgres, plus the standard NestJS+Prisma `PrismaService extends PrismaClient` pattern this adapter expects.
46
+
47
+ ## License
48
+
49
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-dash/prisma",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Prisma adapter for NestJS Dash (ResourceAdapter/DatabaseAdapter implementation)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@nestjs-dash/adapter": "1.0.0",
21
- "@nestjs-dash/core": "1.0.0"
21
+ "@nestjs-dash/core": "1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@nestjs-dash/typescript-config": "0.1.0",