@orkestrel/relation 0.0.10 → 0.0.12
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 +14 -14
- package/dist/src/core/index.cjs +284 -104
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +461 -121
- package/dist/src/core/index.d.ts +461 -121
- package/dist/src/core/index.js +281 -105
- package/dist/src/core/index.js.map +1 -1
- package/package.json +22 -19
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @orkestrel/relation
|
|
2
2
|
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
> A small, declarative ORM layer over the `@orkestrel/database` tables: a table's
|
|
4
|
+
> relations named once, then records loaded or found with their related rows already
|
|
5
|
+
> attached, batched so a direct relation costs one query across the whole record set and
|
|
6
|
+
> a `through` relation two.
|
|
7
|
+
|
|
8
|
+
Declare each table's relations with the `belongsTo`, `hasMany`, `hasOne`,
|
|
9
|
+
`hasThrough`, and `hasMorph` builders, then reach a typed model through
|
|
10
|
+
`model(name)` and drop to `model.table` for plain typed reads and writes.
|
|
11
|
+
Environment-agnostic — no I/O, no browser or server assumptions. Part of the
|
|
12
|
+
`@orkestrel` line.
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
@@ -19,8 +19,8 @@ npm install @orkestrel/relation
|
|
|
19
19
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
|
-
- Node.js >=
|
|
23
|
-
- ESM
|
|
22
|
+
- Node.js >= 22.12.0, matching the `engines` field in `package.json`
|
|
23
|
+
- ESM (`import`) and CommonJS (`require`) through the `exports` field
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
@@ -42,8 +42,8 @@ const manager = createRelationManager({
|
|
|
42
42
|
database: db,
|
|
43
43
|
relations: {
|
|
44
44
|
accounts: {
|
|
45
|
-
classification: belongsTo('classificationId', 'classifications'), //
|
|
46
|
-
contacts: hasMany('accountId'), //
|
|
45
|
+
classification: belongsTo('classificationId', 'classifications'), // foreign key on accounts
|
|
46
|
+
contacts: hasMany('accountId'), // foreign key on contacts → back here
|
|
47
47
|
},
|
|
48
48
|
contacts: { account: belongsTo('accountId', 'accounts') },
|
|
49
49
|
},
|