nestjs-drizzle-crud 2.1.0 → 2.1.1
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.
- package/README.md +17 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,22 +63,32 @@ DrizzleCrudModule.forFeature([{ service: UsersService, table: users }]);
|
|
|
63
63
|
## Installation
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
+
pnpm add nestjs-drizzle-crud
|
|
67
|
+
# or
|
|
66
68
|
npm install nestjs-drizzle-crud
|
|
69
|
+
# or
|
|
70
|
+
yarn add nestjs-drizzle-crud
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
Peer dependencies (install the ones you use):
|
|
70
74
|
|
|
71
75
|
```bash
|
|
72
76
|
# always
|
|
73
|
-
|
|
77
|
+
pnpm add @nestjs/common @nestjs/core drizzle-orm reflect-metadata
|
|
74
78
|
|
|
75
79
|
# PostgreSQL (also required if you use `connectionString` with dialect 'postgresql')
|
|
76
|
-
|
|
80
|
+
pnpm add postgres
|
|
77
81
|
|
|
78
82
|
# MySQL
|
|
79
|
-
|
|
83
|
+
pnpm add mysql2
|
|
80
84
|
```
|
|
81
85
|
|
|
86
|
+
> Using npm or yarn? Swap `pnpm add` for `npm install` / `yarn add`.
|
|
87
|
+
|
|
88
|
+
> **pnpm note:** `postgres`/`mysql2` are optional peer dependencies. pnpm enforces
|
|
89
|
+
> peer deps strictly, so if you build the connection from a `connectionString`
|
|
90
|
+
> make sure the matching driver is installed in your app.
|
|
91
|
+
|
|
82
92
|
> `postgres` is an **optional** peer dependency. It's only needed when you let the
|
|
83
93
|
> module build the connection from a `connectionString` for the `postgresql` dialect.
|
|
84
94
|
> If you pass a pre-built `db` instead, you don't need it.
|
|
@@ -137,13 +147,13 @@ import type { User } from '../db/schema';
|
|
|
137
147
|
|
|
138
148
|
export interface CreateUserDto { name: string; email: string }
|
|
139
149
|
export interface UpdateUserDto { name?: string; email?: string }
|
|
140
|
-
export interface
|
|
150
|
+
export interface UserFilterDto { name?: string; email?: string }
|
|
141
151
|
|
|
142
152
|
export class UsersService extends SqlBaseCrudService<
|
|
143
153
|
User,
|
|
144
154
|
CreateUserDto,
|
|
145
155
|
UpdateUserDto,
|
|
146
|
-
|
|
156
|
+
UserFilterDto
|
|
147
157
|
> {}
|
|
148
158
|
```
|
|
149
159
|
|
|
@@ -289,7 +299,7 @@ Add custom behaviour by overriding hooks (see [Lifecycle hooks](#lifecycle-hooks
|
|
|
289
299
|
or add your own methods:
|
|
290
300
|
|
|
291
301
|
```typescript
|
|
292
|
-
export class UsersService extends SqlBaseCrudService<User, CreateUserDto, UpdateUserDto,
|
|
302
|
+
export class UsersService extends SqlBaseCrudService<User, CreateUserDto, UpdateUserDto, UserFilterDto> {
|
|
293
303
|
findByEmail(email: string) {
|
|
294
304
|
return this.findOne({ email } as Partial<User>);
|
|
295
305
|
}
|
|
@@ -608,7 +618,7 @@ Concise, accurate facts for code generation. Prefer these over guessing.
|
|
|
608
618
|
|
|
609
619
|
**A service is an empty subclass — do NOT inject the db or pass `dialect`/`db`:**
|
|
610
620
|
```typescript
|
|
611
|
-
export class XService extends SqlBaseCrudService<X, CreateXDto, UpdateXDto,
|
|
621
|
+
export class XService extends SqlBaseCrudService<X, CreateXDto, UpdateXDto, XFilterDto> {}
|
|
612
622
|
```
|
|
613
623
|
|
|
614
624
|
**Rules / gotchas:**
|