@stonyx/orm 0.3.2-alpha.117 → 0.3.2-alpha.118
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 +27 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -46,6 +46,21 @@ not put them on disk, and none of them is loaded unless your configuration asks
|
|
|
46
46
|
for it. Add only the ones you actually use — see
|
|
47
47
|
[Optional peer dependencies](#optional-peer-dependencies).
|
|
48
48
|
|
|
49
|
+
## Exports
|
|
50
|
+
|
|
51
|
+
| Import path | What it exports |
|
|
52
|
+
| :--- | :--- |
|
|
53
|
+
| `@stonyx/orm` | `Orm` (default), `store`, `relationships`, the base classes `Model`, `View`, `Serializer`, the aggregate helpers `count`, `avg`, `sum`, `min`, `max` (see [docs/views.md](https://github.com/abofs/stonyx-orm/blob/dev/docs/views.md)), the helpers listed in [Exported Helpers](#exported-helpers), and the types `OrmAccessRequest` and `PersistErrorDetail` |
|
|
54
|
+
| `@stonyx/orm/db` | the live DB instance (default), `data` (its record) and `saveDB()`. It reads `Orm.db` when it is imported, so import it only after the ORM has initialized |
|
|
55
|
+
| `@stonyx/orm/standalone-db` | `StandaloneDB` (default): reads and writes the JSON db files directly, without booting Stonyx or the ORM |
|
|
56
|
+
| `@stonyx/orm/migrate` | `fileToDirectory()`, `directoryToFile()`: convert the JSON db between file and directory mode |
|
|
57
|
+
| `@stonyx/orm/commands` | the `db:*` command map (default) that the Stonyx CLI loads; see [Database (DB) Integration](#database-db-integration) |
|
|
58
|
+
| `@stonyx/orm/hooks` | `beforeHook`, `afterHook`, `clearHook`, `clearAllHooks`, `getBeforeHooks`, `getAfterHooks`, and the `HookContext` type |
|
|
59
|
+
|
|
60
|
+
## Samples
|
|
61
|
+
|
|
62
|
+
[`test/sample/`](https://github.com/abofs/stonyx-orm/tree/dev/test/sample) is the canonical usage reference: models, serializers, transforms, views and an access class that the test suite loads as a running app, so they stay correct. It is not included in the npm package.
|
|
63
|
+
|
|
49
64
|
## Usage example
|
|
50
65
|
|
|
51
66
|
This module is part of the **Stonyx framework**. To use it, first configure the `restServer` key in your `environment.js` file:
|
|
@@ -355,12 +370,20 @@ MySQL integration tests run automatically when MySQL is available. In CI (where
|
|
|
355
370
|
|
|
356
371
|
## REST Server Integration
|
|
357
372
|
|
|
358
|
-
The ORM
|
|
373
|
+
The ORM registers REST routes for the models your access classes name. It does this itself during initialization when `restServer.enabled` is `'true'`; there is no setup function to import or call. Configure it in `config/environment.js`:
|
|
359
374
|
|
|
360
375
|
```js
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
376
|
+
export default {
|
|
377
|
+
orm: {
|
|
378
|
+
paths: {
|
|
379
|
+
access: './access' // directory of access classes
|
|
380
|
+
},
|
|
381
|
+
restServer: {
|
|
382
|
+
enabled: 'true', // requires @stonyx/rest-server, see Optional peer dependencies
|
|
383
|
+
route: '/' // mount prefix for the generated routes
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
364
387
|
```
|
|
365
388
|
|
|
366
389
|
Access classes define models and provide custom filtering/authorization logic:
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"stonyx-async",
|
|
5
5
|
"stonyx-module"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.3.2-alpha.
|
|
7
|
+
"version": "0.3.2-alpha.118",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"type": "module",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"homepage": "https://github.com/abofs/stonyx-orm#readme",
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@stonyx/cron": "0.2.1-beta.
|
|
65
|
-
"@stonyx/events": "0.1.1-beta.
|
|
66
|
-
"@stonyx/utils": "0.2.3-beta.
|
|
67
|
-
"stonyx": "0.2.3-beta.
|
|
64
|
+
"@stonyx/cron": "0.2.1-beta.149",
|
|
65
|
+
"@stonyx/events": "0.1.1-beta.68",
|
|
66
|
+
"@stonyx/utils": "0.2.3-beta.28",
|
|
67
|
+
"stonyx": "0.2.3-beta.101"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@aws-sdk/client-dynamodb": "^3.0.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@stonyx/rest-server": "0.2.1-beta.
|
|
94
|
+
"@stonyx/rest-server": "0.2.1-beta.151",
|
|
95
95
|
"@types/node": "^25.6.0",
|
|
96
96
|
"mysql2": "^3.20.0",
|
|
97
97
|
"pg": "^8.20.0",
|