@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 CHANGED
@@ -1,15 +1,15 @@
1
1
  # @orkestrel/relation
2
2
 
3
- A typed **relation manager** over [`@orkestrel/database`](https://github.com/orkestrel/database)
4
- tables — name a table's relations once, then `load` / `find` records with their
5
- related rows already attached. Loading is **batched** — a direct relation uses
6
- one query across the whole record set, while a `through` relation uses two
7
- (junction then target); either count stays constant as the parent count grows.
8
- Five relation kinds
9
- (`belongs` / `many` / `one` / `through` / `morph`) cover the FK shapes; nested
10
- includes recurse through the registry; `link` / `unlink` / `links` manage a
11
- many-to-many junction without hand-writing join rows. Environment-agnostic —
12
- no I/O, no browser or server assumptions. Part of the `@orkestrel` line.
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 >= 24
23
- - ESM-only (no CommonJS build)
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'), // FK on accounts
46
- contacts: hasMany('accountId'), // FK on contacts → back here
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
  },