viborm 1.0.0-rc.5 → 1.1.0
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 +104 -658
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/adapter-internals-n3Mf3css.mjs +2 -0
- package/dist/{adapter-internals-BgKoAIFp.mjs.map → adapter-internals-n3Mf3css.mjs.map} +1 -1
- package/dist/adapter-namespace-DMhEF6my.mjs +2 -0
- package/dist/{adapter-namespace-DfkdF4Or.mjs.map → adapter-namespace-DMhEF6my.mjs.map} +1 -1
- package/dist/adapters.d.mts +2 -2
- package/dist/adapters.mjs +1 -1
- package/dist/adapters.mjs.map +1 -1
- package/dist/array-literal-DcEm5tt_.mjs +2 -0
- package/dist/array-literal-DcEm5tt_.mjs.map +1 -0
- package/dist/base-vfur-DaU.mjs +2 -0
- package/dist/base-vfur-DaU.mjs.map +1 -0
- package/dist/batch-refs-Op1fx9Bo.mjs +6 -0
- package/dist/batch-refs-Op1fx9Bo.mjs.map +1 -0
- package/dist/bind-parameter-capacity-DzMcIB95.mjs +2 -0
- package/dist/{bind-parameter-capacity-EaN7GwPH.mjs.map → bind-parameter-capacity-DzMcIB95.mjs.map} +1 -1
- package/dist/builder-DkWfNHEV.mjs +2 -0
- package/dist/builder-DkWfNHEV.mjs.map +1 -0
- package/dist/bun-sql.d.mts +120 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sql.mjs.map +1 -1
- package/dist/bun-sqlite.d.mts +70 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/bun-sqlite.mjs.map +1 -1
- package/dist/cache/cloudflare-kv.d.mts +17 -1
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/cloudflare-kv.mjs.map +1 -1
- package/dist/cache/memory.d.mts +17 -2
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache/memory.mjs.map +1 -1
- package/dist/cache.d.mts +13 -1
- package/dist/cache.mjs +1 -1
- package/dist/cache.mjs.map +1 -1
- package/dist/chain-uIFlkkXS.mjs +2 -0
- package/dist/chain-uIFlkkXS.mjs.map +1 -0
- package/dist/chunk-BuuaeEvq.mjs +1 -0
- package/dist/cli.mjs +6 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/client-C8gXvWIA.mjs +2 -0
- package/dist/client-C8gXvWIA.mjs.map +1 -0
- package/dist/client-z9mcpRtA.mjs +435 -0
- package/dist/client-z9mcpRtA.mjs.map +1 -0
- package/dist/client.d.mts +2 -3
- package/dist/client.mjs +1 -1
- package/dist/clock-W8H2Khng.mjs +2 -0
- package/dist/{clock-CFwoNfK6.mjs.map → clock-W8H2Khng.mjs.map} +1 -1
- package/dist/config.d.mts +15 -6
- package/dist/config.mjs +1 -1
- package/dist/{contract-e7yuSaVa.d.mts → contract-BHUOUAZ-.d.mts} +1 -2
- package/dist/controls-BhxRnPYS.mjs +2 -0
- package/dist/{controls-Cal9dSs_.mjs.map → controls-BhxRnPYS.mjs.map} +1 -1
- package/dist/current-DyzK6OCh.mjs +2 -0
- package/dist/{current-RBfT4OO9.mjs.map → current-DyzK6OCh.mjs.map} +1 -1
- package/dist/d1.d.mts +64 -1
- package/dist/d1.mjs +1 -1
- package/dist/d1.mjs.map +1 -1
- package/dist/datetime-physical-codec-BK93pJGW.mjs +2 -0
- package/dist/datetime-physical-codec-BK93pJGW.mjs.map +1 -0
- package/dist/driver-CHclfK3q.mjs +2 -0
- package/dist/driver-CHclfK3q.mjs.map +1 -0
- package/dist/driver-ZIbkciaz.mjs +2 -0
- package/dist/driver-ZIbkciaz.mjs.map +1 -0
- package/dist/driver-options-DVxWlZ0s.mjs +2 -0
- package/dist/driver-options-DVxWlZ0s.mjs.map +1 -0
- package/dist/driver.d.mts +2 -3
- package/dist/driver.mjs +1 -1
- package/dist/error-mapping-LKqxnw-b.mjs +2 -0
- package/dist/error-mapping-LKqxnw-b.mjs.map +1 -0
- package/dist/execution-context-Bm_qTp1i.mjs +2 -0
- package/dist/execution-context-Bm_qTp1i.mjs.map +1 -0
- package/dist/fs-estate-3Bu_K9mk.d.mts +7 -0
- package/dist/fs-estate-BLqNdigQ.mjs +2 -0
- package/dist/{fs-estate-TRIOfc_M.mjs.map → fs-estate-BLqNdigQ.mjs.map} +1 -1
- package/dist/geo-area-codec-B4DRInvA.mjs +2 -0
- package/dist/{geo-area-codec-DK_LapaJ.mjs.map → geo-area-codec-B4DRInvA.mjs.map} +1 -1
- package/dist/geo-point-codec-DUTTtlav.mjs +2 -0
- package/dist/geo-point-codec-DUTTtlav.mjs.map +1 -0
- package/dist/hydration-D6JICBQG.mjs +2 -0
- package/dist/{hydration-8QIqXL9h.mjs.map → hydration-D6JICBQG.mjs.map} +1 -1
- package/dist/identifier-EsWKVHXi.mjs +2 -0
- package/dist/{identifier-BOd29Um5.mjs.map → identifier-EsWKVHXi.mjs.map} +1 -1
- package/dist/index-BbcE-gyl.d.mts +13313 -0
- package/dist/index.d.mts +3 -7
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/instrumentation.d.mts +4 -5
- package/dist/instrumentation.mjs +1 -1
- package/dist/instrumentation.mjs.map +1 -1
- package/dist/invariant-DCsftyml.mjs +2 -0
- package/dist/{invariant-jQVxbI0-.mjs.map → invariant-DCsftyml.mjs.map} +1 -1
- package/dist/json-number-TpD-pfqt.mjs +2 -0
- package/dist/json-number-TpD-pfqt.mjs.map +1 -0
- package/dist/key-DKaqPb8w.mjs +2 -0
- package/dist/key-DKaqPb8w.mjs.map +1 -0
- package/dist/libsql.d.mts +54 -1
- package/dist/libsql.mjs +1 -1
- package/dist/libsql.mjs.map +1 -1
- package/dist/migrations/storage/fs.d.mts +1 -1
- package/dist/migrations/storage/fs.mjs +1 -1
- package/dist/migrations-BWZSBMZh.mjs +2 -0
- package/dist/{migrations-dxCedohw.mjs.map → migrations-BWZSBMZh.mjs.map} +1 -1
- package/dist/migrations.d.mts +29 -485
- package/dist/migrations.mjs +1 -1
- package/dist/migrations.mjs.map +1 -1
- package/dist/mysql-adapter-DtZdwqzc.mjs +2 -0
- package/dist/mysql-adapter-DtZdwqzc.mjs.map +1 -0
- package/dist/mysql2.d.mts +90 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/mysql2.mjs.map +1 -1
- package/dist/native-types-veeTk36s.mjs +2 -0
- package/dist/{native-types-CXpXeqMI.mjs.map → native-types-veeTk36s.mjs.map} +1 -1
- package/dist/neon-http.d.mts +61 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/neon-http.mjs.map +1 -1
- package/dist/observation-CLp8ylmL.mjs +2 -0
- package/dist/{observation-B5DIb5m5.mjs.map → observation-CLp8ylmL.mjs.map} +1 -1
- package/dist/pg.d.mts +119 -2
- package/dist/pg.mjs +1 -1
- package/dist/pg.mjs.map +1 -1
- package/dist/pglite.d.mts +95 -2
- package/dist/pglite.mjs +1 -1
- package/dist/pglite.mjs.map +1 -1
- package/dist/physical-BkelResN.mjs +2 -0
- package/dist/physical-BkelResN.mjs.map +1 -0
- package/dist/pinned-session-CNANv7bv.mjs +2 -0
- package/dist/{pinned-session-BrcntNGj.mjs.map → pinned-session-CNANv7bv.mjs.map} +1 -1
- package/dist/planetscale.d.mts +46 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/planetscale.mjs.map +1 -1
- package/dist/planner-Bbw8W81b.d.mts +432 -0
- package/dist/postgres-adapter-ButxrmEa.mjs +2 -0
- package/dist/postgres-adapter-ButxrmEa.mjs.map +1 -0
- package/dist/postgres-result-Dc_iW3Hb.mjs +2 -0
- package/dist/{postgres-result-PPyctOGl.mjs.map → postgres-result-Dc_iW3Hb.mjs.map} +1 -1
- package/dist/postgres.d.mts +87 -2
- package/dist/postgres.mjs +1 -1
- package/dist/postgres.mjs.map +1 -1
- package/dist/provider-limits-DXj_pOT0.mjs +2 -0
- package/dist/{provider-limits-C5BGSa_y.mjs.map → provider-limits-DXj_pOT0.mjs.map} +1 -1
- package/dist/registration-preflight-BrA3EWvq.mjs +4 -0
- package/dist/registration-preflight-BrA3EWvq.mjs.map +1 -0
- package/dist/result-parsing-DRXC89ek.mjs +2 -0
- package/dist/{result-parsing-Vzrh6wXZ.mjs.map → result-parsing-DRXC89ek.mjs.map} +1 -1
- package/dist/result-shape-CKLOBSKl.mjs +2 -0
- package/dist/result-shape-CKLOBSKl.mjs.map +1 -0
- package/dist/scalar-BTktMqvO.mjs +2 -0
- package/dist/scalar-BTktMqvO.mjs.map +1 -0
- package/dist/schema/json.d.mts +9 -10
- package/dist/schema/json.mjs +1 -1
- package/dist/schema/json.mjs.map +1 -1
- package/dist/schema-BFNcMdO6.mjs +2 -0
- package/dist/{schema-DHec0Xje.mjs.map → schema-BFNcMdO6.mjs.map} +1 -1
- package/dist/schema-introspection-C7P7lwIs.mjs +6 -0
- package/dist/{schema-introspection-B-kD3MA7.mjs.map → schema-introspection-C7P7lwIs.mjs.map} +1 -1
- package/dist/schema.d.mts +2 -4
- package/dist/schema.mjs +1 -1
- package/dist/select-assembly-BgqlrePH.mjs +2 -0
- package/dist/select-assembly-BgqlrePH.mjs.map +1 -0
- package/dist/soft-delete.d.mts +89 -47
- package/dist/soft-delete.mjs +1 -1
- package/dist/soft-delete.mjs.map +1 -1
- package/dist/sql--69HUgel.mjs +2 -0
- package/dist/sql--69HUgel.mjs.map +1 -0
- package/dist/{sql-DKzSK495.d.mts → sql--yhoVvRM.d.mts} +5 -7
- package/dist/sql-statement-tokens-CykxFmOJ.mjs +3 -0
- package/dist/{sql-statement-tokens-lngJf_E4.mjs.map → sql-statement-tokens-CykxFmOJ.mjs.map} +1 -1
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/sqlite-adapter-1krz0OXw.mjs +2 -0
- package/dist/sqlite-adapter-1krz0OXw.mjs.map +1 -0
- package/dist/sqlite-utils-D26BFuJJ.mjs +2 -0
- package/dist/sqlite-utils-D26BFuJJ.mjs.map +1 -0
- package/dist/sqlite3.d.mts +84 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/sqlite3.mjs.map +1 -1
- package/dist/suppressed-failure-BPxfHTMc.mjs +2 -0
- package/dist/{suppressed-failure-DTwn7Y9f.mjs.map → suppressed-failure-BPxfHTMc.mjs.map} +1 -1
- package/dist/terminal-BbRi0CNZ.mjs +2 -0
- package/dist/terminal-BbRi0CNZ.mjs.map +1 -0
- package/dist/transaction-operation-BC7aua5V.mjs +2 -0
- package/dist/transaction-operation-BC7aua5V.mjs.map +1 -0
- package/dist/transaction-oskVwmsf.mjs +2 -0
- package/dist/transaction-oskVwmsf.mjs.map +1 -0
- package/dist/transactions-gjmrWN5W.mjs +2 -0
- package/dist/transactions-gjmrWN5W.mjs.map +1 -0
- package/dist/types-C4v6iAmY.mjs +2 -0
- package/dist/{types-C7oiscf7.mjs.map → types-C4v6iAmY.mjs.map} +1 -1
- package/dist/utils-CRFUUfNn.mjs +25 -0
- package/dist/utils-CRFUUfNn.mjs.map +1 -0
- package/dist/v-B2WwtcRz.mjs +2 -0
- package/dist/v-B2WwtcRz.mjs.map +1 -0
- package/dist/validation-Du6j0Q38.mjs +2 -0
- package/dist/validation-Du6j0Q38.mjs.map +1 -0
- package/dist/validation-tgjL_9n8.mjs +2 -0
- package/dist/validation-tgjL_9n8.mjs.map +1 -0
- package/dist/validation.d.mts +2 -2
- package/dist/validation.mjs +1 -1
- package/dist/validator-DMlEScV3.mjs +2 -0
- package/dist/validator-DMlEScV3.mjs.map +1 -0
- package/dist/version-De1l_ZMF.mjs +2 -0
- package/dist/{version-BGlY3i8l.mjs.map → version-De1l_ZMF.mjs.map} +1 -1
- package/package.json +69 -41
- package/dist/adapter-internals-BgKoAIFp.mjs +0 -2
- package/dist/adapter-namespace-DfkdF4Or.mjs +0 -2
- package/dist/base-BWVndwlC.mjs +0 -2
- package/dist/base-BWVndwlC.mjs.map +0 -1
- package/dist/bind-parameter-capacity-EaN7GwPH.mjs +0 -2
- package/dist/builder-DqKlQ_Mx.mjs +0 -2
- package/dist/builder-DqKlQ_Mx.mjs.map +0 -1
- package/dist/chain-DzVie35E.mjs +0 -2
- package/dist/chain-DzVie35E.mjs.map +0 -1
- package/dist/client-B_mAPXJQ.mjs +0 -421
- package/dist/client-B_mAPXJQ.mjs.map +0 -1
- package/dist/client-BvYU6FwM.mjs +0 -2
- package/dist/client-BvYU6FwM.mjs.map +0 -1
- package/dist/clock-CFwoNfK6.mjs +0 -2
- package/dist/controls-Cal9dSs_.mjs +0 -2
- package/dist/current-RBfT4OO9.mjs +0 -2
- package/dist/datetime-physical-codec-DdkWziId.mjs +0 -2
- package/dist/datetime-physical-codec-DdkWziId.mjs.map +0 -1
- package/dist/driver-CoTUqZbX.mjs +0 -2
- package/dist/driver-CoTUqZbX.mjs.map +0 -1
- package/dist/driver-Dg9xLDwr.mjs +0 -2
- package/dist/driver-Dg9xLDwr.mjs.map +0 -1
- package/dist/error-mapping-C5Kb8Ixs.mjs +0 -2
- package/dist/error-mapping-C5Kb8Ixs.mjs.map +0 -1
- package/dist/execution-context-DAx0W2Ta.mjs +0 -2
- package/dist/execution-context-DAx0W2Ta.mjs.map +0 -1
- package/dist/fs-estate-B_zez5wX.d.mts +0 -8
- package/dist/fs-estate-TRIOfc_M.mjs +0 -2
- package/dist/geo-area-codec-DK_LapaJ.mjs +0 -2
- package/dist/geo-point-codec-BnYrqWBm.mjs +0 -2
- package/dist/geo-point-codec-BnYrqWBm.mjs.map +0 -1
- package/dist/hydration-8QIqXL9h.mjs +0 -2
- package/dist/hydration-DY5rGhMw.d.mts +0 -11
- package/dist/identifier-BOd29Um5.mjs +0 -2
- package/dist/identifiers-C_CJoqNj.mjs +0 -2
- package/dist/identifiers-C_CJoqNj.mjs.map +0 -1
- package/dist/index-CCU2fuyp.d.mts +0 -596
- package/dist/index-Cl9KExI4.d.mts +0 -5778
- package/dist/invariant-jQVxbI0-.mjs +0 -2
- package/dist/key-C8RnsRzV.mjs +0 -2
- package/dist/key-C8RnsRzV.mjs.map +0 -1
- package/dist/migrations-dxCedohw.mjs +0 -2
- package/dist/mysql-adapter-DMdiovUJ.mjs +0 -2
- package/dist/mysql-adapter-DMdiovUJ.mjs.map +0 -1
- package/dist/native-types-CXpXeqMI.mjs +0 -2
- package/dist/observation-B5DIb5m5.mjs +0 -2
- package/dist/physical-Bvsf8kcL.mjs +0 -2
- package/dist/physical-Bvsf8kcL.mjs.map +0 -1
- package/dist/pinned-session-BrcntNGj.mjs +0 -2
- package/dist/postgres-adapter-nUXOVV5P.mjs +0 -2
- package/dist/postgres-adapter-nUXOVV5P.mjs.map +0 -1
- package/dist/postgres-result-PPyctOGl.mjs +0 -2
- package/dist/provider-limits-C5BGSa_y.mjs +0 -2
- package/dist/result-parsing-Vzrh6wXZ.mjs +0 -2
- package/dist/result-shape-DnEBdBzs.mjs +0 -2
- package/dist/result-shape-DnEBdBzs.mjs.map +0 -1
- package/dist/scalar-C7ipr_DS.mjs +0 -3
- package/dist/scalar-C7ipr_DS.mjs.map +0 -1
- package/dist/scalar-DX97Y0GR.mjs +0 -2
- package/dist/scalar-DX97Y0GR.mjs.map +0 -1
- package/dist/schema-DHec0Xje.mjs +0 -2
- package/dist/schema-introspection-B-kD3MA7.mjs +0 -6
- package/dist/schema-introspection-qPsFpF1e.d.mts +0 -30
- package/dist/sql-CUMF6uXF.mjs +0 -2
- package/dist/sql-CUMF6uXF.mjs.map +0 -1
- package/dist/sql-statement-tokens-lngJf_E4.mjs +0 -3
- package/dist/sqlite-adapter-CyxVbCWO.mjs +0 -2
- package/dist/sqlite-adapter-CyxVbCWO.mjs.map +0 -1
- package/dist/sqlite-utils-C96mvnGK.mjs +0 -2
- package/dist/sqlite-utils-C96mvnGK.mjs.map +0 -1
- package/dist/standard-sql-DMPeIdq0.mjs +0 -6
- package/dist/standard-sql-DMPeIdq0.mjs.map +0 -1
- package/dist/string-DCs4kGaG.d.mts +0 -7344
- package/dist/suppressed-failure-DTwn7Y9f.mjs +0 -2
- package/dist/terminal-CSvNCH2-.mjs +0 -2
- package/dist/terminal-CSvNCH2-.mjs.map +0 -1
- package/dist/transaction-C2_FESEH.mjs +0 -2
- package/dist/transaction-C2_FESEH.mjs.map +0 -1
- package/dist/transaction-CWIntwlc.d.mts +0 -124
- package/dist/transaction-operation-CG4GHTLI.mjs +0 -2
- package/dist/transaction-operation-CG4GHTLI.mjs.map +0 -1
- package/dist/transactions-BD-ElGn7.mjs +0 -2
- package/dist/transactions-BD-ElGn7.mjs.map +0 -1
- package/dist/types-C7oiscf7.mjs +0 -2
- package/dist/utils-5I2aMDy7.mjs +0 -33
- package/dist/utils-5I2aMDy7.mjs.map +0 -1
- package/dist/v-B_vExfF8.mjs +0 -2
- package/dist/v-B_vExfF8.mjs.map +0 -1
- package/dist/validation-CRv9mpwX.mjs +0 -2
- package/dist/validation-CRv9mpwX.mjs.map +0 -1
- package/dist/validation-DhX0T6mg.mjs +0 -2
- package/dist/validation-DhX0T6mg.mjs.map +0 -1
- package/dist/validator-8wPbBNpj.mjs +0 -2
- package/dist/validator-8wPbBNpj.mjs.map +0 -1
- package/dist/version-BGlY3i8l.mjs +0 -2
package/README.md
CHANGED
|
@@ -1,683 +1,129 @@
|
|
|
1
1
|
# VibORM
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript ORM for PostgreSQL, MySQL and SQLite. Define models in TypeScript;
|
|
4
|
+
query inputs and results are inferred without a code generation step.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
V1 requires Node.js 22+ and TypeScript 5.9+. Bun support depends on the selected
|
|
7
|
+
driver. Read the [upgrade guide](docs/content/docs/getting-started/upgrading-to-v1.mdx)
|
|
8
|
+
before moving from 0.1 or a release candidate.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
The preceding `1.0.0-rc.4` is published. Install an exact published candidate
|
|
9
|
-
for reproducible evaluation; `next` follows the latest published RC.
|
|
10
|
-
V1 includes breaking changes. Read the [upgrade guide](docs/content/docs/getting-started/upgrading-to-v1.mdx)
|
|
11
|
-
and [changelog](CHANGELOG.md) before migrating. Node.js 22 or newer and
|
|
12
|
-
TypeScript 5.8 or newer are the supported Node/TypeScript floors. The docs site
|
|
13
|
-
has its own Node.js requirement.
|
|
10
|
+
## Quick start
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
qualification from hosted preview limits. Publication follows [RELEASING.md](RELEASING.md);
|
|
17
|
-
stable V1 is not released by this preparation step.
|
|
12
|
+
PGlite runs PostgreSQL in your process. This example persists its database locally.
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|---------|-------------|
|
|
23
|
-
| **Zero Codegen** | Types flow from schema → query → result via TypeScript inference |
|
|
24
|
-
| **Standard Schema V1** | Interoperable with Zod, Valibot, ArkType for validation |
|
|
25
|
-
| **Prisma-inspired API** | Familiar `findMany`, `create`, `update` operations with `where`, `include`, `select` |
|
|
26
|
-
| **Multi-Database** | PostgreSQL, MySQL, SQLite from one codebase via adapter pattern |
|
|
27
|
-
| **Chainable Schema** | `s.string().nullable().unique()` with immutable state tracking |
|
|
28
|
-
|
|
29
|
-
## Prisma Compatibility Snapshot
|
|
30
|
-
|
|
31
|
-
VibORM is Prisma-inspired, not a full Prisma clone. The matrix below compares the normal Prisma Client relational CRUD/query surface with VibORM's current documented contract. `Supported` means the input works for the documented surface or rejects before query generation; it does not mean every Prisma preview, provider-specific, or unsafe API exists.
|
|
32
|
-
|
|
33
|
-
Detailed contract: [client compatibility](docs/content/docs/client/compatibility.mdx) and [Prisma parity contract](docs/architecture/prisma-parity-contract.md). Prisma baseline: [CRUD](https://www.prisma.io/docs/orm/prisma-client/queries/crud) and [aggregation/grouping](https://www.prisma.io/docs/orm/prisma-client/queries/aggregation-grouping-summarizing).
|
|
34
|
-
|
|
35
|
-
Status legend:
|
|
36
|
-
|
|
37
|
-
| Status | Meaning |
|
|
38
|
-
|--------|---------|
|
|
39
|
-
| `Supported` | Same core shape as Prisma for the documented relational SQL surface |
|
|
40
|
-
| `Subset` | Prisma supports more shapes; VibORM supports a smaller fail-closed subset |
|
|
41
|
-
| `Different` | Intentional VibORM API decision |
|
|
42
|
-
| `Unsupported` | Not part of the current public contract |
|
|
43
|
-
|
|
44
|
-
### Basic CRUD
|
|
45
|
-
|
|
46
|
-
| Area | Prisma Client | VibORM | Status |
|
|
47
|
-
|------|---------------|--------|--------|
|
|
48
|
-
| Single-record reads | `findUnique`, `findUniqueOrThrow`, `findFirst`, `findFirstOrThrow` with `where`, `orderBy`, `select`, `include` | Same core operations; unique reads require a real unique discriminator (which may be narrowed by non-unique scalar filters and `AND`/`OR`/`NOT`, Prisma ≥4.5) and or-throw variants throw `NotFoundError` | `Supported` |
|
|
49
|
-
| Multi-record reads | `findMany` with filters, ordering, pagination, `distinct`, `select`, `include` | Supports scalar/relation filters, scalar and supported relation ordering, cursor/offset pagination, negative `take`, `distinct`, `select`, `include` | `Supported` |
|
|
50
|
-
| Create one | `create` with scalar data, nested writes, `select`, `include` | Supports scalar data and documented nested writes; unsupported nested write keys reject before parent mutation | `Supported` |
|
|
51
|
-
| Create many | `createMany` returns `{ count }`; `createManyAndReturn` is a separate provider-specific method | `createMany` returns `{ count }`, or the inserted rows when the call carries a `select` (implicit returning — there is no `createManyAndReturn` method); `skipDuplicates` skips duplicate-key conflicts only, and combining it with `select` needs a `RETURNING` dialect | `Different` |
|
|
52
|
-
| Update one | `update` by unique selector; returns updated row; supports atomic numeric ops and nested writes | Requires unique `where`; throws on missing row; supports scalar updates, atomic numeric ops, and documented nested writes | `Supported` |
|
|
53
|
-
| Update many | `updateMany` returns `{ count }`; `updateManyAndReturn` is a separate provider-specific method | `updateMany` returns `{ count }`, or the updated rows when the call carries a `select` (implicit returning — there is no `updateManyAndReturn` method) | `Different` |
|
|
54
|
-
| Upsert | `upsert` with unique `where`, `create`, `update`; returns row | Same core shape; supported nested writes are allowed in covered branches | `Supported` |
|
|
55
|
-
| Delete | `delete` by unique selector returns deleted row; `deleteMany` returns `{ count }` | Same core shape; `delete` throws on missing row and non-returning dialects fetch before delete where safe. `deleteMany` additionally returns the deleted rows when the call carries a `select` — a superset Prisma has no form of | `Different` |
|
|
56
|
-
|
|
57
|
-
### Advanced Queries
|
|
58
|
-
|
|
59
|
-
| Area | Prisma Client | VibORM | Status |
|
|
60
|
-
|------|---------------|--------|--------|
|
|
61
|
-
| Scalar filters | `where` with scalar operators and `AND`/`OR`/`NOT` | Supports documented scalar operators and logical filters; unknown/unsupported operators reject before SQL generation | `Supported` |
|
|
62
|
-
| Relation filters | To-one `is`/`isNot`; to-many `some`/`every`/`none` | Same documented relation filter surface, including nested relation filters where covered | `Supported` |
|
|
63
|
-
| Projection | `select`, `include`, nested selection, relation `_count` | Supports `select`, `include`, nested selection, and relation `_count`; top-level `select` + `include` rejects | `Supported` |
|
|
64
|
-
| Sorting | Scalar-field `orderBy`, to-one relation order by scalar fields, to-many relation `_count` order, aggregate/group ordering, provider-specific relevance ordering | Supports scalar-field order, to-one relation order by scalar fields, to-many relation `_count`, and documented aggregate/group ordering; unsupported to-many scalar-field order and `_relevance` reject | `Subset` |
|
|
65
|
-
| Pagination | `cursor`, `skip`, `take`, negative `take` on list reads | Supports cursor pagination, `skip`, `take`, negative `take`; cursor uses `whereUnique` | `Supported` |
|
|
66
|
-
| `distinct` | `findMany({ distinct })` with Prisma's in-memory distinct semantics | Supports scalar-field `distinct`; relation fields reject; SQL strategy is adapter-owned | `Subset` |
|
|
67
|
-
| `count` | Count records and selected non-null fields; supports filters and pagination-style args | Supports `where`, selected count fields, and `orderBy`/`cursor`/`take`/`skip` input-window pagination | `Supported` |
|
|
68
|
-
| `aggregate` | `_count`, `_avg`, `_sum`, `_min`, `_max` with `where`, order, pagination | Same documented aggregate selectors and input-window pagination; invalid/empty aggregate selection rejects | `Supported` |
|
|
69
|
-
| `groupBy` | `by`, aggregates, `having`, `orderBy`, `skip`, `take`; no `select` | Supports scalar `by`, aggregate selections, `having`, order, `skip`, `take`; invalid group/having shapes reject | `Supported` |
|
|
70
|
-
| Nested writes | Broad nested create/connect/update/delete/upsert matrix | Supports `create`, `createMany`, `connect`, `connectOrCreate`, nullable/correlated `disconnect`, `delete`, `set`, `update`, to-many `updateMany`, `upsert`, and to-many `deleteMany`; callback-transaction and atomic-batch paths propagate generated and updated primary keys where the shape is safe; create-branch update/delete-like shapes are excluded | `Subset` |
|
|
71
|
-
| Transactions | Callback and array `$transaction` | Callback transactions on transactional drivers; batch mode on transactional or atomic-batch drivers | `Supported` |
|
|
72
|
-
| `omit` | Prisma supports per-query and client-level `omit` | Supports per-query `omit` plus the official `defaultOmit()` client extension, and lets query-level `omit` subtract from `select`; the local `{ field: false }` override of that default also works. VibORM additionally has a schema-level `.omit()` that is a hard exclusion no query can undo | `Different` |
|
|
73
|
-
| Raw SQL | Prisma tagged `$queryRaw`/`$executeRaw` plus unsafe variants | Tagged `$queryRaw` (returns `T[]`) / `$executeRaw` (returns the affected count) plus `$queryRawUnsafe`/`$executeRawUnsafe`; lazy raw operations mix with model operations in array transactions and also run on the interactive transaction client. `sql`/`join`/`empty`/`raw` are exported from the package root | `Supported` |
|
|
74
|
-
| Existence check | Emulated with `count`/`findFirst` in Prisma | `exist({ where })` is a VibORM extension returning `boolean`; no `exists` alias | `Different` |
|
|
14
|
+
```sh
|
|
15
|
+
pnpm add viborm @electric-sql/pglite
|
|
16
|
+
```
|
|
75
17
|
|
|
76
|
-
```
|
|
18
|
+
```ts
|
|
77
19
|
import { s } from "viborm";
|
|
78
20
|
import { createClient } from "viborm/pglite";
|
|
21
|
+
import { createMigrationClient } from "viborm/migrations";
|
|
79
22
|
|
|
80
|
-
// Schema carries type information
|
|
81
23
|
const user = s.model({
|
|
82
24
|
id: s.string().id().ulid(),
|
|
83
25
|
email: s.string().unique(),
|
|
84
26
|
posts: s.toMany(() => post),
|
|
85
27
|
});
|
|
86
|
-
|
|
87
28
|
const post = s.model({
|
|
88
29
|
id: s.string().id().ulid(),
|
|
89
30
|
title: s.string(),
|
|
90
|
-
authorId: s.string(),
|
|
91
|
-
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Fully typed queries - no codegen!
|
|
95
|
-
const orm = createClient({ schema: { user, post } });
|
|
96
|
-
|
|
97
|
-
const users = await orm.user.findMany({
|
|
98
|
-
where: { email: { contains: "@company.com" } }, // ← TypeScript knows email is string
|
|
99
|
-
include: { posts: true } // ← Result includes typed posts[]
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## Quick Start (PGlite)
|
|
106
|
-
|
|
107
|
-
PGlite runs PostgreSQL in-process via WebAssembly—no Docker or external database needed. Perfect for development and testing.
|
|
108
|
-
|
|
109
|
-
### 1. Install
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
pnpm add viborm @electric-sql/pglite
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 2. Define Schema
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
// schema.ts
|
|
119
|
-
import { s } from "viborm";
|
|
120
|
-
|
|
121
|
-
export const user = s.model({
|
|
122
|
-
id: s.string().id().ulid(),
|
|
123
|
-
name: s.string(),
|
|
124
|
-
email: s.string().unique(),
|
|
125
|
-
createdAt: s.dateTime().now(),
|
|
126
|
-
posts: s.toMany(() => post),
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export const post = s.model({
|
|
130
|
-
id: s.string().id().ulid(),
|
|
131
|
-
title: s.string(),
|
|
132
|
-
content: s.string().nullable(),
|
|
133
|
-
authorId: s.string(),
|
|
31
|
+
authorId: s.string().ulid(),
|
|
134
32
|
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
135
33
|
});
|
|
136
34
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
### 3. Create Client & Push Schema
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
// db.ts
|
|
144
|
-
import { createClient } from "viborm/pglite";
|
|
145
|
-
import { createMigrationClient } from "viborm/migrations";
|
|
146
|
-
import { schema } from "./schema";
|
|
147
|
-
|
|
148
|
-
export const orm = createClient({
|
|
149
|
-
schema,
|
|
150
|
-
dataDir: ".pglite", // Persists to filesystem (omit for in-memory)
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// History-free live sync. Push never writes estate storage or the marker.
|
|
154
|
-
const migrations = createMigrationClient(orm);
|
|
155
|
-
await migrations.push();
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 4. Query
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
// Create
|
|
162
|
-
const newUser = await orm.user.create({
|
|
163
|
-
data: { name: "Alice", email: "alice@example.com" }
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// Read with relations
|
|
167
|
-
const usersWithPosts = await orm.user.findMany({
|
|
168
|
-
include: { posts: true }
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Filter
|
|
172
|
-
const alice = await orm.user.findFirst({
|
|
173
|
-
where: { email: { contains: "alice" } }
|
|
174
|
-
});
|
|
35
|
+
const db = createClient({ schema: { user, post }, dataDir: ".pglite" });
|
|
36
|
+
await createMigrationClient(db).push();
|
|
175
37
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
38
|
+
const alice = await db.user.create({
|
|
39
|
+
data: {
|
|
40
|
+
email: "alice@example.com",
|
|
41
|
+
posts: { create: { title: "Hello" } },
|
|
42
|
+
},
|
|
43
|
+
include: { posts: true },
|
|
180
44
|
});
|
|
181
45
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Transactions
|
|
191
|
-
|
|
192
|
-
VibORM supports callback transactions on drivers with real transaction support, and batch mode on drivers with transactions or native atomic batch support.
|
|
193
|
-
|
|
194
|
-
### Callback Mode (Dynamic)
|
|
195
|
-
|
|
196
|
-
```typescript
|
|
197
|
-
const result = await orm.$transaction(async (tx) => {
|
|
198
|
-
const user = await tx.user.create({
|
|
199
|
-
data: { name: "Alice", email: "alice@example.com" }
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
await tx.post.create({
|
|
203
|
-
data: { title: "First Post", authorId: user.id }
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
return user;
|
|
207
|
-
});
|
|
208
|
-
// If any operation fails, all changes are rolled back
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Batch Mode (Array)
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
const [user, post] = await orm.$transaction([
|
|
215
|
-
orm.user.create({ data: { name: "Bob", email: "bob@example.com" } }),
|
|
216
|
-
orm.post.create({ data: { title: "Hello", authorId: "user-id" } })
|
|
217
|
-
]);
|
|
218
|
-
// Executes atomically when the driver supports transactions or native batch
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## Client Extensions
|
|
224
|
-
|
|
225
|
-
`$extends()` returns an immutable derived client. Extensions have six distinct
|
|
226
|
-
capabilities: `request`, `query`, `statement`, `observe`, `client`, and `model`.
|
|
227
|
-
See the [extension guide](docs/content/docs/extensions/index.mdx) for their
|
|
228
|
-
authority and exact lifecycle.
|
|
229
|
-
|
|
230
|
-
Internally, `src/extensions/` is the single generic definition, chain,
|
|
231
|
-
method-binding, admission, and capability-runner boundary. The official
|
|
232
|
-
implementations remain with their domains in `src/cache/extension.ts`,
|
|
233
|
-
`src/instrumentation/extension.ts`, and
|
|
234
|
-
`src/client/default-omit-extension.ts`; client, query-engine, and drivers only
|
|
235
|
-
retain the lifecycle trigger points whose facts they create.
|
|
236
|
-
|
|
237
|
-
Client default projection is also an extension:
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
import { defaultOmit } from "viborm/client";
|
|
241
|
-
|
|
242
|
-
const publicOrm = orm.$extends(
|
|
243
|
-
defaultOmit<typeof schema>()({
|
|
244
|
-
user: { passwordHash: true },
|
|
245
|
-
})
|
|
246
|
-
);
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
`defaultOmit()` is a presentation default, not authorization. VibORM does not
|
|
250
|
-
currently ship an RBAC helper; complete policy must account for the full query
|
|
251
|
-
and mutation graph.
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
## Caching
|
|
256
|
-
|
|
257
|
-
VibORM provides query caching as an official client extension, with TTL and
|
|
258
|
-
stale-while-revalidate (SWR) support.
|
|
259
|
-
|
|
260
|
-
### Setup
|
|
261
|
-
|
|
262
|
-
```typescript
|
|
263
|
-
import { createClient } from "viborm/pglite";
|
|
264
|
-
import { cache } from "viborm/cache";
|
|
265
|
-
import { MemoryCache } from "viborm/cache/memory";
|
|
266
|
-
|
|
267
|
-
const orm = createClient({ schema }).$extends(
|
|
268
|
-
cache({ driver: new MemoryCache() })
|
|
269
|
-
);
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Basic Caching
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
// Cache for 5 minutes (default)
|
|
276
|
-
const users = await orm.$withCache().user.findMany();
|
|
277
|
-
|
|
278
|
-
// Custom TTL
|
|
279
|
-
const posts = await orm.$withCache({ ttl: "1 hour" }).post.findMany();
|
|
280
|
-
|
|
281
|
-
// TTL in milliseconds
|
|
282
|
-
const recent = await orm.$withCache({ ttl: 30000 }).user.findMany();
|
|
283
|
-
|
|
284
|
-
// A custom key is a suffix of the canonical model/operation/argument key.
|
|
285
|
-
const active = await orm
|
|
286
|
-
.$withCache({ key: "active-users" })
|
|
287
|
-
.user.findMany({ where: { active: true } });
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### Stale-While-Revalidate (SWR)
|
|
291
|
-
|
|
292
|
-
SWR returns stale data immediately while revalidating in the background:
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
// Enable SWR with default 2x TTL stale window
|
|
296
|
-
const users = await orm.$withCache({ ttl: "5 minutes", swr: true }).user.findMany();
|
|
297
|
-
|
|
298
|
-
// Custom SWR window
|
|
299
|
-
const posts = await orm.$withCache({ ttl: "5 minutes", swr: "1 hour" }).post.findMany();
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### Cache Invalidation
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
// Auto-invalidate model cache after mutations
|
|
306
|
-
await orm.user.create({
|
|
307
|
-
data: { name: "Alice", email: "alice@example.com" },
|
|
308
|
-
cache: { autoInvalidate: true } // Invalidates all user:* cache keys
|
|
46
|
+
const posts = await db.post.findMany({
|
|
47
|
+
where: { authorId: alice.id },
|
|
48
|
+
select: { id: true, title: true },
|
|
49
|
+
orderBy: { title: "asc" },
|
|
309
50
|
});
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
##
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
| `time()` | Time only | `s.time()` |
|
|
390
|
-
| `json()` | JSON with schema validation | `s.json(zodSchema)` |
|
|
391
|
-
| `enum()` | Enumerated values | `s.enum(["ADMIN", "USER"])` |
|
|
392
|
-
| `blob()` | Binary data (Uint8Array) | `s.blob()` |
|
|
393
|
-
| `vector()` | Vector embeddings (pgvector) | `s.vector(1536)` |
|
|
394
|
-
| `point()` | PostGIS point type | `import { point } from "viborm"` (not exposed on `s`) |
|
|
395
|
-
|
|
396
|
-
### Auto-generation
|
|
397
|
-
|
|
398
|
-
```typescript
|
|
399
|
-
s.string().id().uuid() // UUID v4
|
|
400
|
-
s.string().id().uuidv7() // UUID v7 (time-sortable)
|
|
401
|
-
s.string().id().ulid() // ULID
|
|
402
|
-
s.string().id().ksuid() // KSUID (time-sortable)
|
|
403
|
-
s.string().id().nanoid() // NanoID
|
|
404
|
-
s.string().id().cuid() // CUID2
|
|
405
|
-
s.int().id().increment() // Auto-increment
|
|
406
|
-
s.dateTime().now() // Current timestamp on create
|
|
407
|
-
s.dateTime().updatedAt() // Update timestamp on every update
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Every one of those is generated by VibORM itself, from `crypto.getRandomValues`.
|
|
411
|
-
Naming a format is also a promise about the field's values: it is validated, and
|
|
412
|
-
`uuid`, `uuidv7`, `ulid` and `ksuid` are stored as the identifier rather than as
|
|
413
|
-
its text. See [String scalars](https://viborm.dev/docs/schema/scalars/string)
|
|
414
|
-
and, for a table that already holds text,
|
|
415
|
-
[Converting identifier columns](https://viborm.dev/docs/migration/identifiers).
|
|
416
|
-
|
|
417
|
-
---
|
|
418
|
-
|
|
419
|
-
## Runtime Dependencies
|
|
420
|
-
|
|
421
|
-
VibORM installs one runtime dependency for the core package, and one CLI-only
|
|
422
|
-
pair. No entry the client bundle reaches imports any of them; the CLI pair is
|
|
423
|
-
imported by `dist/cli.mjs` and by nothing else:
|
|
424
|
-
|
|
425
|
-
| Package | Why it is a dependency |
|
|
426
|
-
|---|---|
|
|
427
|
-
| `@standard-schema/spec` | Types only — the interface every validator here speaks |
|
|
428
|
-
| `@clack/prompts`, `commander` | The CLI only, imported by `dist/cli.mjs` |
|
|
429
|
-
|
|
430
|
-
There is no value-type dependency and no hash dependency: the exact decimal and
|
|
431
|
-
SHA3-512 are VibORM's own, and the `v.*` validation primitives always were.
|
|
432
|
-
|
|
433
|
-
What left the graph, and what replaced it:
|
|
434
|
-
|
|
435
|
-
| Removed | Replaced by |
|
|
436
|
-
|---|---|
|
|
437
|
-
| `decimal.js` | VibORM's own `Decimal` over a `BigInt` coefficient — a deliberate API change, documented in the changelog |
|
|
438
|
-
| `@paralleldrive/cuid2` | VibORM's own CUID2, byte-identical to it (proven by a differential test against the pinned package, which remains a devDependency for exactly that test) |
|
|
439
|
-
| `nanoid` | VibORM's own NanoID |
|
|
440
|
-
| `ulidx` | VibORM's own ULID, with unbiased randomness and the same monotonicity |
|
|
441
|
-
| `@noble/hashes` | VibORM's own SHA3-512, proven byte-identical to it over the NIST known-answer vectors and 10,000 random messages (the package remains a devDependency for exactly that test) |
|
|
442
|
-
|
|
443
|
-
Database drivers (`pg`, `mysql2`, `better-sqlite3`, …) are never dependencies:
|
|
444
|
-
you install the one you use.
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
## Supported Drivers
|
|
449
|
-
|
|
450
|
-
### PostgreSQL
|
|
451
|
-
|
|
452
|
-
| Driver | Package | Use Case |
|
|
453
|
-
|--------|---------|----------|
|
|
454
|
-
| `pglite` | `@electric-sql/pglite` | Development, testing (WASM) |
|
|
455
|
-
| `pg` | `pg` | Node.js with node-postgres |
|
|
456
|
-
| `postgres` | `postgres` | Node.js with postgres.js |
|
|
457
|
-
| `neon-http` | `@neondatabase/serverless` | Neon serverless (HTTP) |
|
|
458
|
-
|
|
459
|
-
### MySQL
|
|
460
|
-
|
|
461
|
-
| Driver | Package | Use Case |
|
|
462
|
-
|--------|---------|----------|
|
|
463
|
-
| `mysql2` | `mysql2` | Node.js with mysql2 |
|
|
464
|
-
| `planetscale` | `@planetscale/database` | PlanetScale serverless |
|
|
465
|
-
|
|
466
|
-
### SQLite
|
|
467
|
-
|
|
468
|
-
| Driver | Package | Use Case |
|
|
469
|
-
|--------|---------|----------|
|
|
470
|
-
| `sqlite3` | `better-sqlite3` | Node.js (synchronous) |
|
|
471
|
-
| `libsql` | `@libsql/client` | Turso / LibSQL |
|
|
472
|
-
| `d1` | Cloudflare binding | Cloudflare D1 (Workers) |
|
|
473
|
-
| `bun-sqlite` | Built-in | Bun runtime |
|
|
474
|
-
|
|
475
|
-
---
|
|
476
|
-
|
|
477
|
-
## Repository Structure
|
|
478
|
-
|
|
479
|
-
VibORM uses a **12-layer architecture**. Each layer has an `AGENTS.md` with detailed documentation.
|
|
480
|
-
|
|
481
|
-
```
|
|
482
|
-
src/
|
|
483
|
-
├── validation/ L1 Standard Schema V1 primitives (v.*)
|
|
484
|
-
│ Branded types, set-theory optimization
|
|
485
|
-
│
|
|
486
|
-
├── schema/ L2-L5 Schema definition
|
|
487
|
-
│ ├── scalars/ Scalar types with State generic pattern
|
|
488
|
-
│ ├── model/ Model composition, query schemas
|
|
489
|
-
│ ├── relation/ The two relation factories and their state
|
|
490
|
-
│ └── validation/ Definition-time schema validation
|
|
491
|
-
│
|
|
492
|
-
├── query-engine/ L6 Database-agnostic query building
|
|
493
|
-
│ Decides WHAT to query, delegates HOW to adapters
|
|
494
|
-
│
|
|
495
|
-
├── adapters/ L7 Database-specific SQL generation
|
|
496
|
-
│ PostgreSQL, MySQL, SQLite dialect implementations
|
|
497
|
-
│
|
|
498
|
-
├── drivers/ L8 Connection management, query execution
|
|
499
|
-
│ 11 drivers: pglite, pg, postgres, neon-http, bun-sql,
|
|
500
|
-
│ mysql2, planetscale, sqlite3, libsql, d1, bun-sqlite
|
|
501
|
-
│
|
|
502
|
-
├── extensions/ Cross-cutting six-capability contracts, immutable chain,
|
|
503
|
-
│ method binding, runners, and array-admission latch
|
|
504
|
-
│
|
|
505
|
-
├── client/ L9 Type inference, ORM interface
|
|
506
|
-
│ Recursive proxy pattern, result types
|
|
507
|
-
│
|
|
508
|
-
├── cache/ L10 Query caching, invalidation, stale-while-revalidate
|
|
509
|
-
│
|
|
510
|
-
├── instrumentation/ L11 Tracing, structured logging, diagnostics
|
|
511
|
-
│
|
|
512
|
-
└── migrations/ L12 Authenticated estate, history-free push, DDL
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
### Key Architecture Rules
|
|
516
|
-
|
|
517
|
-
1. **Query Engine / Adapter Separation**: Query engine decides WHAT to query, adapter decides HOW to express it in SQL. Never hardcode dialect-specific syntax in query-engine.
|
|
518
|
-
|
|
519
|
-
2. **Natural Type Inference**: Never use type assertions (`as`). Types flow from schema → validation → client.
|
|
520
|
-
|
|
521
|
-
3. **Immutable State**: Every scalar modifier returns a NEW instance. `s.string().nullable()` returns a new scalar, doesn't mutate.
|
|
522
|
-
|
|
523
|
-
4. **Lazy Evaluation**: Schemas are built on first access (`??=` pattern) and cached.
|
|
524
|
-
|
|
525
|
-
---
|
|
526
|
-
|
|
527
|
-
## Development
|
|
528
|
-
|
|
529
|
-
### Prerequisites
|
|
530
|
-
|
|
531
|
-
```bash
|
|
532
|
-
pnpm install
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
### Testing (Vitest)
|
|
536
|
-
|
|
537
|
-
We use [Vitest](https://vitest.dev/) for testing. Tests run against PGlite by default—no external database needed.
|
|
538
|
-
|
|
539
|
-
```bash
|
|
540
|
-
pnpm test # Run all tests
|
|
541
|
-
pnpm test:watch # Watch mode
|
|
542
|
-
pnpm test:ui # ⭐ Interactive UI - great for exploring/debugging tests
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
Run a specific test file:
|
|
546
|
-
|
|
547
|
-
```bash
|
|
548
|
-
pnpm vitest run tests/validation/string.test.ts
|
|
549
|
-
pnpm vitest run -t "validates strings" # Run by test name pattern
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
### Build Commands
|
|
553
|
-
|
|
554
|
-
```bash
|
|
555
|
-
pnpm build # Compile TypeScript
|
|
556
|
-
pnpm type-check # Type check only (faster)
|
|
557
|
-
pnpm package:build # Build distributable with tsdown
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
### Path Aliases
|
|
561
|
-
|
|
562
|
-
```typescript
|
|
563
|
-
import { ... } from "@schema"; // src/schema/
|
|
564
|
-
import { ... } from "@client"; // src/client/
|
|
565
|
-
import { ... } from "@validation"; // src/validation/
|
|
566
|
-
import { ... } from "@query-engine/*"; // direct src/query-engine/ owner
|
|
567
|
-
import { ... } from "@adapters"; // src/adapters/
|
|
568
|
-
import { ... } from "@drivers"; // src/drivers/
|
|
569
|
-
import { ... } from "@sql"; // src/sql/
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
---
|
|
573
|
-
|
|
574
|
-
## Agent-First Codebase
|
|
575
|
-
|
|
576
|
-
This codebase is designed for **AI agents to help developers**. Each major directory contains an `AGENTS.md` file—comprehensive architectural documentation that AI assistants can read to understand:
|
|
577
|
-
|
|
578
|
-
- **Why** the layer exists and what problems it solves
|
|
579
|
-
- **Entry points** and key files to modify
|
|
580
|
-
- **Core rules** that must never be broken
|
|
581
|
-
- **Anti-patterns** to avoid
|
|
582
|
-
- **Step-by-step guides** for common tasks
|
|
583
|
-
|
|
584
|
-
**Key documentation:**
|
|
585
|
-
- `AGENTS.md` — Full architectural overview (start here)
|
|
586
|
-
- `FEATURE_IMPLEMENTATION_TEMPLATE.md` — Step-by-step guide for implementing features and fixing bugs, with layer-by-layer analysis framework and code patterns
|
|
587
|
-
|
|
588
|
-
When working with an AI assistant, point it to these files first.
|
|
589
|
-
|
|
590
|
-
### Navigating the Codebase
|
|
591
|
-
|
|
592
|
-
| I want to... | Start here |
|
|
593
|
-
|--------------|------------|
|
|
594
|
-
| Add new scalar type | `src/schema/scalars/AGENTS.md` |
|
|
595
|
-
| Add query operator | `src/query-engine/AGENTS.md` + `src/adapters/AGENTS.md` |
|
|
596
|
-
| Fix type inference bug | `src/client/AGENTS.md` → check upstream schemas |
|
|
597
|
-
| Add migration operation | `src/migrations/AGENTS.md` |
|
|
598
|
-
| Add relation feature | `src/schema/relation/AGENTS.md` |
|
|
599
|
-
| Understand validation | `src/validation/AGENTS.md` |
|
|
600
|
-
|
|
601
|
-
---
|
|
602
|
-
|
|
603
|
-
## Test Structure
|
|
604
|
-
|
|
605
|
-
Tests mirror the `src/` structure:
|
|
606
|
-
|
|
607
|
-
```
|
|
608
|
-
tests/
|
|
609
|
-
├── validation/ 28 tests for v.* primitives
|
|
610
|
-
├── scalars/ Schema generation per scalar type
|
|
611
|
-
├── model/ Query schemas (where, create, update, args)
|
|
612
|
-
│ ├── filter/ WHERE clause generation
|
|
613
|
-
│ ├── create/ CREATE input schemas
|
|
614
|
-
│ ├── update/ UPDATE input schemas
|
|
615
|
-
│ └── args/ Operation argument schemas
|
|
616
|
-
├── query-engine/ SQL generation tests
|
|
617
|
-
├── relations/ Relation CRUD operations
|
|
618
|
-
├── client/ End-to-end client operations
|
|
619
|
-
├── migrations/ Schema diffing and DDL
|
|
620
|
-
└── drivers/ Database-specific driver tests
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
Most tests run against PGlite (in-memory PostgreSQL). Driver tests in `tests/drivers/` require external databases.
|
|
624
|
-
|
|
625
|
-
---
|
|
626
|
-
|
|
627
|
-
## Common Pitfalls
|
|
628
|
-
|
|
629
|
-
| Mistake | Why it breaks | Fix |
|
|
630
|
-
|---------|---------------|-----|
|
|
631
|
-
| Hardcoded SQL in query-engine | Breaks MySQL/SQLite | Use `ctx.adapter.*` methods |
|
|
632
|
-
| Type assertions (`as`) | Hides type mismatches | Let types flow naturally |
|
|
633
|
-
| Forgot Scalar union update | New scalar type invisible | Update `src/schema/scalars/base.ts` |
|
|
634
|
-
| Direct model reference in relation | ReferenceError at runtime | Use thunk `() => model` |
|
|
635
|
-
| Eager schema building | Performance (rebuilds every access) | Use `??=` lazy pattern |
|
|
636
|
-
| Mutation instead of new instance | Type/runtime desync | Return new instance from modifiers |
|
|
637
|
-
|
|
638
|
-
---
|
|
639
|
-
|
|
640
|
-
## Current Status
|
|
641
|
-
|
|
642
|
-
**Core features working:**
|
|
643
|
-
- All CRUD operations (create, read, update, delete, upsert)
|
|
644
|
-
- Relations: two factories, `s.toOne` and `s.toMany`, over one model or a map of named variants. Every ordinary cardinality cell (one-to-one, one-to-many, many-to-many) and both variant cardinalities are derived from the declared pair, each with direct and inverse read/write surfaces
|
|
645
|
-
- Supported nested writes (`create`, `createMany`, `connect`, `connectOrCreate`, `disconnect`, `delete`, `set`, `update`, `updateMany`, `upsert`, `deleteMany`) across callback-transaction and atomic-batch paths
|
|
646
|
-
- Select/include with typed results
|
|
647
|
-
- Recursive relation projections (`recurse` on a self-relation in `select`/`include`, `WITH RECURSIVE` underneath): implemented through the ordinary projection, executed locally on SQLite, PGlite, PostgreSQL and MySQL; hosted providers not yet qualified (`features-docs/recursive-query.md`)
|
|
648
|
-
- All scalar types (string, int, number, boolean, dateTime, json, enum, etc.)
|
|
649
|
-
- PostgreSQL, MySQL, and SQLite adapters, including authenticated estate migrations and history-free `push` where the provider lock/CAS is proven
|
|
650
|
-
- Query caching with TTL and SWR
|
|
651
|
-
- Transactions (callback and batch modes), with Prisma's `{ isolationLevel, timeout, maxWait }` options honored or refused per driver — never ignored
|
|
652
|
-
- OpenTelemetry instrumentation
|
|
653
|
-
|
|
654
|
-
**Known limitations:**
|
|
655
|
-
- Full Prisma parity is not complete; VibORM is Prisma-inspired.
|
|
656
|
-
- Parent `create` and the create branch of parent `upsert` intentionally exclude update/delete-like nested operations.
|
|
657
|
-
- Impossible or unsafe primary-key dataflow shapes reject before mutation instead of partially applying nested writes.
|
|
658
|
-
- Raw queries are Prisma-shaped tagged templates; the pre-1.0 `$queryRaw(string, params?)` form still runs for one release behind a deprecation notice. Raw calls are lazy, promise-compatible operations that can mix with model operations in `$transaction([...])`.
|
|
659
|
-
- Transaction options are honored where the driver can honor them and refused with a typed `UnsupportedOperationError` (naming the option and the reason) where it cannot; see the per-driver table in the Transactions docs.
|
|
660
|
-
- Local nested-write conformance is proven on PGlite/Postgres-style and SQLite-family paths; hosted D1 binding and Neon HTTP need external runs before claiming hosted verification.
|
|
661
|
-
|
|
662
|
-
See `PENDING_WORK.md` for detailed tracking.
|
|
663
|
-
|
|
664
|
-
---
|
|
665
|
-
|
|
666
|
-
## Internal API Convention
|
|
667
|
-
|
|
668
|
-
All internal state is accessed via `["~"]`:
|
|
669
|
-
|
|
670
|
-
```typescript
|
|
671
|
-
scalar["~"].state // ScalarState - configuration object
|
|
672
|
-
scalar["~"].state.base // Base scalar schema
|
|
673
|
-
schemaRegistry.proxy.user.core.where // Operation schema for this model
|
|
674
|
-
relation["~"].state.getter // Thunk to target model
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
This keeps the public API clean and signals "internal" to developers.
|
|
678
|
-
|
|
679
|
-
---
|
|
680
|
-
|
|
681
|
-
## License
|
|
682
|
-
|
|
683
|
-
MIT
|
|
51
|
+
await db.$disconnect();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A format such as `.ulid()` defines the value domain. ID fields generate values by
|
|
55
|
+
default; a non-ID field does not generate a missing foreign key. Supplied clients
|
|
56
|
+
remain owned by their caller.
|
|
57
|
+
|
|
58
|
+
For application projects, keep the client and schema in separate modules and use
|
|
59
|
+
[the CLI](docs/content/docs/getting-started/configuration.mdx):
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// viborm.config.ts
|
|
63
|
+
import { defineConfig } from "viborm/config";
|
|
64
|
+
import { db } from "./src/db";
|
|
65
|
+
export default defineConfig({ client: db });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
pnpm exec viborm check
|
|
70
|
+
pnpm exec viborm push
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The CLI loads a project `.env` and TypeScript configuration using its bundled
|
|
74
|
+
loader. Choose a persistent database path or explicit connection URL in the
|
|
75
|
+
client. `push` synchronizes the live schema; versioned migration files use the
|
|
76
|
+
separate [migration workflow](docs/content/docs/migration/index.mdx).
|
|
77
|
+
|
|
78
|
+
## What it provides
|
|
79
|
+
|
|
80
|
+
- Inferred CRUD, filters, relations, aggregates, pagination and nested writes.
|
|
81
|
+
- Immutable scalar declarations and Standard Schema validation.
|
|
82
|
+
- PostgreSQL, MySQL and SQLite adapters with eleven transport drivers.
|
|
83
|
+
- Callback transactions where the provider supports them, and atomic array
|
|
84
|
+
transactions on the supported batch transports.
|
|
85
|
+
- Ten extension capabilities: `request`, `query`, `statement`, `observe`, `client`,
|
|
86
|
+
`model`, `controls`, `rows`, `deletion` and `data`; official cache,
|
|
87
|
+
instrumentation, omit and soft-delete tools.
|
|
88
|
+
- Fixed-decimal values, millisecond DateTime values, GeoPoint and PostgreSQL vector
|
|
89
|
+
operations with explicit provider requirements.
|
|
90
|
+
|
|
91
|
+
See the [driver matrix](docs/content/docs/drivers/index.mdx) for actual provider
|
|
92
|
+
qualification and hosted limitations. SQL Server, a database browser, read-replica
|
|
93
|
+
routing and cross-schema relations are not implemented.
|
|
94
|
+
|
|
95
|
+
## Contracts to know
|
|
96
|
+
|
|
97
|
+
VibORM has a Prisma-inspired API, with differences documented in the
|
|
98
|
+
[compatibility guide](docs/content/docs/client/compatibility.mdx).
|
|
99
|
+
|
|
100
|
+
- Operations are lazy: awaiting an operation executes it. Reusing that same
|
|
101
|
+
operation reuses its completion; create a new operation for another execution.
|
|
102
|
+
- `createMany`, `updateMany` and `deleteMany` return `{ count }`, or rows when a
|
|
103
|
+
supported `select` is supplied. `exist()` returns a boolean.
|
|
104
|
+
- Use one of `select` or `include` at each projection level.
|
|
105
|
+
- `omit` controls row presentation. Filters, aggregates and raw SQL can still
|
|
106
|
+
address omitted columns; it is not an authorization boundary.
|
|
107
|
+
- Safe raw SQL parameterizes values; it does not apply model codecs. Compact IDs,
|
|
108
|
+
SQLite decimals and temporal columns have physical representations described in
|
|
109
|
+
the [raw SQL guide](docs/content/docs/client/raw-sql.mdx).
|
|
110
|
+
- `undefined` omits a filter. Validate external input before building mutation
|
|
111
|
+
filters. Empty logical filters and provider collation differences are explicit
|
|
112
|
+
in the filtering and compatibility guides.
|
|
113
|
+
- Shared database access and native indexes can require an explicit migration
|
|
114
|
+
decision. Push and migrate refuse unsupported storage; typed queries do not
|
|
115
|
+
inspect it, so audit an adopted SQLite database with `viborm check --db`
|
|
116
|
+
([SQLite migration guide](docs/content/docs/migration/drivers/sqlite.mdx)).
|
|
117
|
+
|
|
118
|
+
## Documentation and development
|
|
119
|
+
|
|
120
|
+
Start with [installation](docs/content/docs/getting-started/index.mdx),
|
|
121
|
+
[queries](docs/content/docs/client/index.mdx),
|
|
122
|
+
[schemas](docs/content/docs/schema/index.mdx) and
|
|
123
|
+
[extensions](docs/content/docs/extensions/index.mdx).
|
|
124
|
+
|
|
125
|
+
Development commands and test lanes are in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
126
|
+
Release provenance and publishing are governed by [RELEASING.md](RELEASING.md).
|
|
127
|
+
See [SECURITY.md](SECURITY.md) for private vulnerability reporting.
|
|
128
|
+
|
|
129
|
+
[MIT](LICENSE).
|