query-builder-prisma 0.2.0 → 0.2.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 +36 -16
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
```ts
|
|
13
13
|
const { meta, data } = await new QueryBuilder(prisma.user)
|
|
14
14
|
.search({ searchText: q, fields: ['email', 'username'] }) // dialect-aware
|
|
15
|
-
.filter({ role, status })
|
|
15
|
+
.filter({ role, status }) // undefined values stripped
|
|
16
16
|
.range({ createdAt: { from, to }, 'avatar.size': { from: min } })
|
|
17
17
|
.sortBy({ sortBy: 'createdAt', sortOrder: 'desc' })
|
|
18
|
-
.paginate({ page: 1, limit: 20 })
|
|
19
|
-
.select({ id: true, email: true })
|
|
18
|
+
.paginate({ page: 1, limit: 20 }) // or .cursorPaginate({...})
|
|
19
|
+
.select({ id: true, email: true }) // output type narrows structurally
|
|
20
20
|
.executeWithMeta();
|
|
21
21
|
// meta: { page: 1, limit: 20, total: 142, totalPage: 8 }
|
|
22
22
|
```
|
|
@@ -51,13 +51,13 @@ runtime dependencies.
|
|
|
51
51
|
|
|
52
52
|
## Documentation
|
|
53
53
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
| [Getting started](./docs/getting-started.md)
|
|
57
|
-
| [Guides](./docs/
|
|
58
|
-
| [API reference](./docs/api/query-builder.md)
|
|
59
|
-
| [Use cases](./docs/examples/use-cases.md)
|
|
60
|
-
| [Framework recipes](./docs/framework-recipes.md)
|
|
54
|
+
| | |
|
|
55
|
+
| ------------------------------------------------ | ----------------------------------------------------------------------------------- |
|
|
56
|
+
| [Getting started](./docs/getting-started.md) | install, first query, imports |
|
|
57
|
+
| [Guides](./docs/readme.md#guides) | filtering, sorting, both pagination modes, projections, dialects, advanced patterns |
|
|
58
|
+
| [API reference](./docs/api/query-builder.md) | every method, type and function |
|
|
59
|
+
| [Use cases](./docs/examples/use-cases.md) | end-to-end scenarios |
|
|
60
|
+
| [Framework recipes](./docs/framework-recipes.md) | Next.js, NestJS, Express, edge runtimes |
|
|
61
61
|
|
|
62
62
|
## Features
|
|
63
63
|
|
|
@@ -84,7 +84,7 @@ runtime dependencies.
|
|
|
84
84
|
const { meta, data } = await new QueryBuilder(prisma.user)
|
|
85
85
|
.filter({ status: 'ACTIVE' })
|
|
86
86
|
.paginate({ page: 2, limit: 20 })
|
|
87
|
-
.executeWithMeta();
|
|
87
|
+
.executeWithMeta(); // meta: { page: 2, limit: 20, total, totalPage }
|
|
88
88
|
|
|
89
89
|
// Skip the COUNT query on large tables:
|
|
90
90
|
await qb.executeWithMeta({ includeTotal: false }); // total: null, totalPage: null
|
|
@@ -118,8 +118,8 @@ await prisma.user.findMany(qb.buildArgs());
|
|
|
118
118
|
```ts
|
|
119
119
|
import { configQueryBuilder } from 'query-builder-prisma';
|
|
120
120
|
|
|
121
|
-
configQueryBuilder({ dialect: 'postgresql' });
|
|
122
|
-
new QueryBuilder(prisma.user, { dialect: 'mysql' });
|
|
121
|
+
configQueryBuilder({ dialect: 'postgresql' }); // global default
|
|
122
|
+
new QueryBuilder(prisma.user, { dialect: 'mysql' }); // per-builder override (recommended)
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
`search()` emits `mode: 'insensitive'` only on PostgreSQL / CockroachDB /
|
|
@@ -206,7 +206,7 @@ Open and documented rather than hidden — none produces a silently wrong result
|
|
|
206
206
|
## FAQ
|
|
207
207
|
|
|
208
208
|
**Does this need Prisma installed?**
|
|
209
|
-
The package never imports Prisma, but of course you query
|
|
209
|
+
The package never imports Prisma, but of course you query _through_ your
|
|
210
210
|
Prisma delegates — you pass them in. Any object with the `findMany` + `count`
|
|
211
211
|
call shape works, which is also how the test suite proves the decoupling.
|
|
212
212
|
|
|
@@ -241,12 +241,32 @@ npm test # unit tests — fake delegates, zero Prisma required
|
|
|
241
241
|
- `src/dialects` — capability registry, per-DB capabilities, auto-detect hook
|
|
242
242
|
- `src/types` — structural delegate contracts + projection type engine
|
|
243
243
|
- `test/types` — compile-time projection tests (run by `npm run typecheck`)
|
|
244
|
-
|
|
244
|
+
|
|
245
|
+
### Releases
|
|
246
|
+
|
|
247
|
+
Releases are fully automatic — there is no manual publish step. Conventional
|
|
248
|
+
Commits on `main` drive the version ([semantic-release](https://semantic-release.org),
|
|
249
|
+
see `.github/workflows/release.yml`):
|
|
250
|
+
|
|
251
|
+
| Commits since the last `v*` tag | Version | Example |
|
|
252
|
+
| ------------------------------------ | ------- | ------------- |
|
|
253
|
+
| `fix:` | patch | 0.2.0 → 0.2.1 |
|
|
254
|
+
| `feat:` | minor | 0.2.0 → 0.3.0 |
|
|
255
|
+
| `feat!:` / `BREAKING CHANGE:` footer | major | 0.2.0 → 1.0.0 |
|
|
256
|
+
| `chore:` / `docs:` / `ci:` / `test:` | none | no release |
|
|
257
|
+
|
|
258
|
+
A release publishes the new version to npm with provenance (the full
|
|
259
|
+
verify pipeline runs first; `package.json` on `main` is not bumped — the `v*`
|
|
260
|
+
tag is the version source of truth), pushes the `v*` tag, and creates the GitHub
|
|
261
|
+
Release with generated notes. [`CHANGELOG.md`](./CHANGELOG.md) stays
|
|
262
|
+
hand-maintained; the auto-generated notes live on
|
|
263
|
+
[GitHub Releases](https://github.com/almamun2b/query-builder-prisma/releases).
|
|
264
|
+
A failed release can be re-run from the Actions tab (`workflow_dispatch`).
|
|
245
265
|
|
|
246
266
|
### Links
|
|
247
267
|
|
|
248
268
|
- [ARCHITECTURE.md](./ARCHITECTURE.md) — design, boundaries, invariants
|
|
249
|
-
- [docs/
|
|
269
|
+
- [docs/readme.md](./docs/readme.md) — full documentation hub
|
|
250
270
|
- [CONTRIBUTING.md](./CONTRIBUTING.md) — how to contribute
|
|
251
271
|
- [SECURITY.md](./SECURITY.md) — vulnerability reporting
|
|
252
272
|
- [CHANGELOG.md](./CHANGELOG.md) — release history
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "query-builder-prisma",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Zero-coupling, fluent, fully type-safe query builder for any Prisma model delegate. Works with every Prisma version (5+, by design all versions) and every database Prisma supports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mamun",
|
|
@@ -50,16 +50,26 @@
|
|
|
50
50
|
"lint": "eslint .",
|
|
51
51
|
"format": "prettier --write .",
|
|
52
52
|
"verify": "npm run lint && npm run typecheck && npm test && npm run build",
|
|
53
|
-
"prepublishOnly": "npm run verify"
|
|
53
|
+
"prepublishOnly": "npm run verify",
|
|
54
|
+
"prepare": "husky"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
57
|
+
"@commitlint/cli": "^21.2.4",
|
|
58
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
56
59
|
"@eslint/js": "^9.17.0",
|
|
57
60
|
"@types/node": "^22.10.0",
|
|
61
|
+
"conventional-commits-filter": "^6.0.1",
|
|
62
|
+
"conventional-commits-parser": "^7.1.3",
|
|
58
63
|
"eslint": "^9.17.0",
|
|
64
|
+
"husky": "^9.1.7",
|
|
59
65
|
"prettier": "^3.4.0",
|
|
66
|
+
"semantic-release": "^25.0.9",
|
|
60
67
|
"tsup": "^8.3.0",
|
|
61
68
|
"typescript": "^5.7.0",
|
|
62
69
|
"typescript-eslint": "^8.18.0",
|
|
63
70
|
"vitest": "^2.1.8"
|
|
71
|
+
},
|
|
72
|
+
"allowScripts": {
|
|
73
|
+
"esbuild": true
|
|
64
74
|
}
|
|
65
75
|
}
|