stonyx 0.2.3-beta.10 → 0.2.3-beta.11

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.
@@ -156,3 +156,35 @@ export default class DBModel extends Model {
156
156
  ```
157
157
 
158
158
  Located at `config/db-schema.js`, referenced from `config/environment.js`.
159
+
160
+ ## Store
161
+
162
+ The store is the in-memory data layer. Use it for internal app logic (not REST API consumers).
163
+
164
+ ```js
165
+ import Orm, { store, createRecord, updateRecord } from '@stonyx/orm';
166
+
167
+ // Read — sync, from memory (requires memory: true on model, which is the default)
168
+ const record = store.get('animal', 1);
169
+ const allAnimals = store.data.get('animals');
170
+
171
+ // Read — async, queries DB if memory: false
172
+ const record = await store.find('animal', 1);
173
+ const all = await store.findAll('animal');
174
+
175
+ // Create — adds to store and returns the record
176
+ const animal = createRecord('animal', { type: 'dog', age: 3, owner: 'angela' });
177
+
178
+ // Update — patches fields on an existing record
179
+ updateRecord(animal, { age: 4 });
180
+
181
+ // Delete
182
+ store.remove('animal', 1);
183
+
184
+ // Persist to disk — required when not using REST-triggered autosave
185
+ await Orm.db.save();
186
+ ```
187
+
188
+ **When to use `Orm.db.save()`**: The `autosave: 'onUpdate'` config only triggers on REST POST/PATCH/DELETE. When modifying data directly via `createRecord` / `updateRecord` in app code (not through REST), call `Orm.db.save()` explicitly to persist.
189
+
190
+ **Store vs REST**: Use `store` for internal app logic (session tracking, state management). Use REST request handlers for external API consumers. Both operate on the same in-memory data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stonyx",
3
- "version": "0.2.3-beta.10",
3
+ "version": "0.2.3-beta.11",
4
4
  "description": "Base stonyx framework module",
5
5
  "main": "main.js",
6
6
  "type": "module",
package/src/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import serve from './cli/serve.js';
4
4
  import test from './cli/test.js';