@stonyx/orm 0.3.2-alpha.120 → 0.3.2-alpha.121

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.
Files changed (2) hide show
  1. package/README.md +11 -8
  2. package/package.json +1 -1
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`: on MySQL/PostgreSQL a model without
747
- // `static memory = true` is not in memory, and `get` returns undefined.
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
- // On SQL the owner resolves only when it is in memory (see MySQL Mode).
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`: on SQL a
853
- // model without `static memory = true` is not in memory. On SQL `animal.owner`
854
- // resolves only when the owner is in memory too, and is `null` otherwise, so this
855
- // check then refuses the owner as well (see MySQL Mode).
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.120",
7
+ "version": "0.3.2-alpha.121",
8
8
  "description": "",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",