@stonyx/orm 0.3.2-alpha.120 → 0.3.2-alpha.122
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 +11 -8
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -325,7 +325,7 @@ Set the `MYSQL_HOST` environment variable to enable MySQL persistence. At startu
|
|
|
325
325
|
|
|
326
326
|
### DynamoDB Mode
|
|
327
327
|
|
|
328
|
-
Set the `DYNAMODB_REGION` environment variable to enable DynamoDB persistence. Tables are created with PAY_PER_REQUEST (on-demand) billing. Global Secondary Indexes (GSIs) are auto-provisioned at startup based on model `belongsTo` relationships — each FK column gets a GSI. `findAll()` with conditions routes to a GSI Query when the condition key matches a GSI partition key; non-indexed attribute conditions fall back to Scan + FilterExpression (expensive for large tables). ULID generation replaces auto-increment for numeric-ID models.
|
|
328
|
+
Set the `DYNAMODB_REGION` environment variable to enable DynamoDB persistence. Tables are created with PAY_PER_REQUEST (on-demand) billing. Global Secondary Indexes (GSIs) are auto-provisioned at startup based on model `belongsTo` relationships — each FK column gets a GSI. `findAll()` with conditions routes to a GSI Query when the condition key matches a GSI partition key; non-indexed attribute conditions fall back to Scan + FilterExpression (expensive for large tables). ULID generation replaces auto-increment for numeric-ID models. The `memory` flag works as in [MySQL Mode](#mysql-mode): only `static memory = true` models are loaded at startup, every other model is read on demand by `store.find()` / `store.findAll()` and is not seen by `store.get()`, and a record read that way resolves a `belongsTo` only when the related record is already in memory.
|
|
329
329
|
|
|
330
330
|
```javascript
|
|
331
331
|
dynamodb: {
|
|
@@ -743,8 +743,9 @@ beforeHook('create', 'animal', (context) => {
|
|
|
743
743
|
// resolved the record by. `context.params.id` is the raw client text and is a
|
|
744
744
|
// different value for every alias of the same id, so a lookup keyed on it
|
|
745
745
|
// finds nothing on a numeric-id model (abofs/stonyx-orm#270).
|
|
746
|
-
// `store.find` rather than `store.get`:
|
|
747
|
-
//
|
|
746
|
+
// `store.find` rather than `store.get`: with a database adapter (MySQL,
|
|
747
|
+
// Postgres, TimescaleDB or DynamoDB) a model without `static memory = true` is
|
|
748
|
+
// not in memory, and `get` returns undefined.
|
|
748
749
|
// Before hooks are awaited, so an async hook works here.
|
|
749
750
|
beforeHook('delete', 'animal', async (context) => {
|
|
750
751
|
const animal = await store.find('animal', context.request.recordId);
|
|
@@ -778,7 +779,8 @@ beforeHook('create', 'owner', (context) => {
|
|
|
778
779
|
// Send notification after animal is adopted.
|
|
779
780
|
// `oldState` holds attributes only, and a belongsTo is the related Record, not
|
|
780
781
|
// its id: capture the previous owner's id before the update, compare ids after.
|
|
781
|
-
//
|
|
782
|
+
// With a database adapter (MySQL, Postgres, TimescaleDB or DynamoDB) the owner
|
|
783
|
+
// resolves only when it is in memory (see MySQL Mode).
|
|
782
784
|
beforeHook('update', 'animal', async (context) => {
|
|
783
785
|
context.state.previousOwnerId = (await store.find('animal', context.request.recordId))?.owner?.id;
|
|
784
786
|
});
|
|
@@ -849,10 +851,11 @@ afterHook('delete', 'animal', async (context) => {
|
|
|
849
851
|
// same value `access()` is handed. Authorizing on `context.params.id` instead
|
|
850
852
|
// looks up the raw client text: on a numeric-id model that lookup returns
|
|
851
853
|
// `undefined` for EVERY spelling, `animal.owner` throws, and the check never
|
|
852
|
-
// runs. Measured; abofs/stonyx-orm#270. `store.find`, not `store.get`:
|
|
853
|
-
//
|
|
854
|
-
//
|
|
855
|
-
//
|
|
854
|
+
// runs. Measured; abofs/stonyx-orm#270. `store.find`, not `store.get`: with a
|
|
855
|
+
// database adapter (MySQL, Postgres, TimescaleDB or DynamoDB) a model without
|
|
856
|
+
// `static memory = true` is not in memory, and `animal.owner` resolves only when
|
|
857
|
+
// the owner is in memory too, and is `null` otherwise, so this check then
|
|
858
|
+
// refuses the owner as well (see MySQL Mode).
|
|
856
859
|
beforeHook('delete', 'animal', async (context) => {
|
|
857
860
|
const user = context.state.currentUser;
|
|
858
861
|
const animal = await store.find('animal', context.request.recordId);
|
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.122",
|
|
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.172",
|
|
65
|
+
"@stonyx/events": "0.1.1-beta.72",
|
|
66
|
+
"@stonyx/utils": "0.2.3-beta.29",
|
|
67
|
+
"stonyx": "0.2.3-beta.107"
|
|
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.175",
|
|
95
95
|
"@types/node": "^25.6.0",
|
|
96
96
|
"mysql2": "^3.20.0",
|
|
97
97
|
"pg": "^8.20.0",
|