metal-orm 1.0.13 → 1.0.14
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 +35 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# MetalORM ⚙️
|
|
1
|
+
# MetalORM ⚙️ - Type-safe SQL, layered ORM, decorator-based entities – all on the same core.
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/metal-orm)
|
|
4
4
|
[](https://github.com/celsowm/metal-orm/blob/main/LICENSE)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
|
-
**Type-safe SQL, layered ORM, decorator-based entities – all on the same core.**
|
|
8
|
-
|
|
9
7
|
MetalORM is a TypeScript-first, AST-driven SQL toolkit you can dial up or down depending on how “ORM-y” you want to be:
|
|
10
8
|
|
|
11
9
|
- **Level 1 – Query builder & hydration 🧩**
|
|
@@ -22,10 +20,10 @@ Use only the layer you need in each part of your codebase.
|
|
|
22
20
|
<a id="table-of-contents"></a>
|
|
23
21
|
## Table of Contents 🧭
|
|
24
22
|
|
|
25
|
-
- [Documentation](#documentation)
|
|
26
|
-
- [Features](#features)
|
|
27
|
-
- [Installation](#installation)
|
|
28
|
-
- [Quick start - three levels](#quick-start)
|
|
23
|
+
- [Documentation](#documentation)
|
|
24
|
+
- [Features](#features)
|
|
25
|
+
- [Installation](#installation)
|
|
26
|
+
- [Quick start - three levels](#quick-start)
|
|
29
27
|
- [Level 1 – Query builder & hydration](#level-1)
|
|
30
28
|
- [Level 2 – Entities + Unit of Work](#level-2)
|
|
31
29
|
- [Level 3 – Decorator entities](#level-3)
|
|
@@ -41,18 +39,18 @@ Use only the layer you need in each part of your codebase.
|
|
|
41
39
|
|
|
42
40
|
Full docs live in the `docs/` folder:
|
|
43
41
|
|
|
44
|
-
- [Introduction](https://github.com/celsowm/metal-orm/blob/main/docs/index.md)
|
|
45
|
-
- [Getting Started](https://github.com/celsowm/metal-orm/blob/main/docs/getting-started.md)
|
|
46
|
-
- [Level 3 Backend Tutorial](https://github.com/celsowm/metal-orm/blob/main/docs/level-3-backend-tutorial.md)
|
|
47
|
-
- [Schema Definition](https://github.com/celsowm/metal-orm/blob/main/docs/schema-definition.md)
|
|
48
|
-
- [Query Builder](https://github.com/celsowm/metal-orm/blob/main/docs/query-builder.md)
|
|
49
|
-
- [DML Operations](https://github.com/celsowm/metal-orm/blob/main/docs/dml-operations.md)
|
|
50
|
-
- [Hydration & Entities](https://github.com/celsowm/metal-orm/blob/main/docs/hydration.md)
|
|
51
|
-
- [Runtime & Unit of Work](https://github.com/celsowm/metal-orm/blob/main/docs/runtime.md)
|
|
52
|
-
- [Advanced Features](https://github.com/celsowm/metal-orm/blob/main/docs/advanced-features.md)
|
|
53
|
-
- [Multi-Dialect Support](https://github.com/celsowm/metal-orm/blob/main/docs/multi-dialect-support.md)
|
|
54
|
-
- [Schema Generation (DDL)](https://github.com/celsowm/metal-orm/blob/main/docs/schema-generation.md)
|
|
55
|
-
- [API Reference](https://github.com/celsowm/metal-orm/blob/main/docs/api-reference.md)
|
|
42
|
+
- [Introduction](https://github.com/celsowm/metal-orm/blob/main/docs/index.md)
|
|
43
|
+
- [Getting Started](https://github.com/celsowm/metal-orm/blob/main/docs/getting-started.md)
|
|
44
|
+
- [Level 3 Backend Tutorial](https://github.com/celsowm/metal-orm/blob/main/docs/level-3-backend-tutorial.md)
|
|
45
|
+
- [Schema Definition](https://github.com/celsowm/metal-orm/blob/main/docs/schema-definition.md)
|
|
46
|
+
- [Query Builder](https://github.com/celsowm/metal-orm/blob/main/docs/query-builder.md)
|
|
47
|
+
- [DML Operations](https://github.com/celsowm/metal-orm/blob/main/docs/dml-operations.md)
|
|
48
|
+
- [Hydration & Entities](https://github.com/celsowm/metal-orm/blob/main/docs/hydration.md)
|
|
49
|
+
- [Runtime & Unit of Work](https://github.com/celsowm/metal-orm/blob/main/docs/runtime.md)
|
|
50
|
+
- [Advanced Features](https://github.com/celsowm/metal-orm/blob/main/docs/advanced-features.md)
|
|
51
|
+
- [Multi-Dialect Support](https://github.com/celsowm/metal-orm/blob/main/docs/multi-dialect-support.md)
|
|
52
|
+
- [Schema Generation (DDL)](https://github.com/celsowm/metal-orm/blob/main/docs/schema-generation.md)
|
|
53
|
+
- [API Reference](https://github.com/celsowm/metal-orm/blob/main/docs/api-reference.md)
|
|
56
54
|
|
|
57
55
|
---
|
|
58
56
|
|
|
@@ -62,16 +60,16 @@ Full docs live in the `docs/` folder:
|
|
|
62
60
|
### Level 1 – Query builder & hydration
|
|
63
61
|
|
|
64
62
|
- **Declarative schema definition** with `defineTable`, `col.*`, and typed relations.
|
|
65
|
-
- **Fluent query builder** over a real SQL AST
|
|
66
|
-
(`SelectQueryBuilder`, `InsertQueryBuilder`, `UpdateQueryBuilder`, `DeleteQueryBuilder`).
|
|
67
|
-
- **Advanced SQL**: CTEs, aggregates, window functions, subqueries, JSON, CASE, EXISTS.
|
|
68
|
-
- **Set operations**: `union`, `unionAll`, `intersect`, `except` across all dialects (ORDER/LIMIT apply to the combined result; hydration is disabled for compound queries so rows are returned as-is without collapsing duplicates).
|
|
69
|
-
- **Expression builders**: `eq`, `and`, `or`, `between`, `inList`, `exists`, `jsonPath`, `caseWhen`, window functions like `rowNumber`, `rank`, `lag`, `lead`, etc., all backed by typed AST nodes.
|
|
70
|
-
- **Relation-aware hydration**: turn flat rows into nested objects (`user.posts`, `user.roles`, etc.) using a hydration plan derived from the AST metadata.
|
|
71
|
-
- **Multi-dialect**: compile once, run on MySQL/MariaDB, PostgreSQL, SQLite, or SQL Server via pluggable dialects.
|
|
72
|
-
- **DML**: type-safe INSERT / UPDATE / DELETE with `RETURNING` where supported.
|
|
73
|
-
|
|
74
|
-
Level 1 is ideal when you:
|
|
63
|
+
- **Fluent query builder** over a real SQL AST
|
|
64
|
+
(`SelectQueryBuilder`, `InsertQueryBuilder`, `UpdateQueryBuilder`, `DeleteQueryBuilder`).
|
|
65
|
+
- **Advanced SQL**: CTEs, aggregates, window functions, subqueries, JSON, CASE, EXISTS.
|
|
66
|
+
- **Set operations**: `union`, `unionAll`, `intersect`, `except` across all dialects (ORDER/LIMIT apply to the combined result; hydration is disabled for compound queries so rows are returned as-is without collapsing duplicates).
|
|
67
|
+
- **Expression builders**: `eq`, `and`, `or`, `between`, `inList`, `exists`, `jsonPath`, `caseWhen`, window functions like `rowNumber`, `rank`, `lag`, `lead`, etc., all backed by typed AST nodes.
|
|
68
|
+
- **Relation-aware hydration**: turn flat rows into nested objects (`user.posts`, `user.roles`, etc.) using a hydration plan derived from the AST metadata.
|
|
69
|
+
- **Multi-dialect**: compile once, run on MySQL/MariaDB, PostgreSQL, SQLite, or SQL Server via pluggable dialects.
|
|
70
|
+
- **DML**: type-safe INSERT / UPDATE / DELETE with `RETURNING` where supported.
|
|
71
|
+
|
|
72
|
+
Level 1 is ideal when you:
|
|
75
73
|
|
|
76
74
|
- Already have a domain model and just want a serious SQL builder.
|
|
77
75
|
- Want deterministic SQL (no magical query generation).
|
|
@@ -83,13 +81,13 @@ On top of the query builder, MetalORM ships a focused runtime:
|
|
|
83
81
|
|
|
84
82
|
- **Entities inferred from your `TableDef`s** (no separate mapping file).
|
|
85
83
|
- **Lazy, batched relations**: `user.posts.load()`, `user.roles.syncByIds([...])`, etc.
|
|
86
|
-
- **Identity map**: the same row becomes the same entity instance within a context (see the [Identity map pattern](https://en.wikipedia.org/wiki/Identity_map_pattern)).
|
|
87
|
-
- **Unit of Work (`OrmContext`)** tracking New/Dirty/Removed entities and relation changes, inspired by the classic [Unit of Work pattern](https://en.wikipedia.org/wiki/Unit_of_work).
|
|
88
|
-
- **Graph persistence**: mutate a whole object graph and flush once with `ctx.saveChanges()`.
|
|
89
|
-
- **Relation change processor** that knows how to deal with has-many and many-to-many pivot tables.
|
|
90
|
-
- **Interceptors**: `beforeFlush` / `afterFlush` hooks for cross-cutting concerns (auditing, multi-tenant filters, soft delete filters, etc.).
|
|
91
|
-
- **Domain events**: `addDomainEvent` and a DomainEventBus integrated into `saveChanges()`, aligned with domain events from [Domain-driven design](https://en.wikipedia.org/wiki/Domain-driven_design).
|
|
92
|
-
- **JSON-safe entities**: relation wrappers hide internal references and implement `toJSON`, so `JSON.stringify` of hydrated entities works without circular reference errors.
|
|
84
|
+
- **Identity map**: the same row becomes the same entity instance within a context (see the [Identity map pattern](https://en.wikipedia.org/wiki/Identity_map_pattern)).
|
|
85
|
+
- **Unit of Work (`OrmContext`)** tracking New/Dirty/Removed entities and relation changes, inspired by the classic [Unit of Work pattern](https://en.wikipedia.org/wiki/Unit_of_work).
|
|
86
|
+
- **Graph persistence**: mutate a whole object graph and flush once with `ctx.saveChanges()`.
|
|
87
|
+
- **Relation change processor** that knows how to deal with has-many and many-to-many pivot tables.
|
|
88
|
+
- **Interceptors**: `beforeFlush` / `afterFlush` hooks for cross-cutting concerns (auditing, multi-tenant filters, soft delete filters, etc.).
|
|
89
|
+
- **Domain events**: `addDomainEvent` and a DomainEventBus integrated into `saveChanges()`, aligned with domain events from [Domain-driven design](https://en.wikipedia.org/wiki/Domain-driven_design).
|
|
90
|
+
- **JSON-safe entities**: relation wrappers hide internal references and implement `toJSON`, so `JSON.stringify` of hydrated entities works without circular reference errors.
|
|
93
91
|
|
|
94
92
|
Use this layer where:
|
|
95
93
|
|
|
@@ -496,4 +494,4 @@ See the contributing guide for details.
|
|
|
496
494
|
<a id="license"></a>
|
|
497
495
|
## License 📄
|
|
498
496
|
|
|
499
|
-
MetalORM is MIT licensed.
|
|
497
|
+
MetalORM is MIT licensed.
|