@kedem/okdb 1.0.4 → 1.1.0

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
@@ -232,7 +232,9 @@ for (const change of db.timeMachine.getChanges('orders', fromClock, toClock)) {
232
232
  Reactive aggregations that update automatically on every write. Declare a view with built-in reducers (`$count`, `$sum`, `$avg`, `$min`, `$max`, `$countBy`) or supply your own, and OKDB keeps the result in sync.
233
233
 
234
234
  ```js
235
- await db.views.create('orderStats', {
235
+ const env = db.env('default');
236
+
237
+ await env.views.create('orderStats', {
236
238
  type: 'orders',
237
239
  filter: { status: 'completed' },
238
240
  reduce: {
@@ -243,11 +245,18 @@ await db.views.create('orderStats', {
243
245
  },
244
246
  });
245
247
 
246
- // Read the live result — synchronous
247
- const stats = db.views.get('orderStats');
248
- // → { total: 142500, count: 312, avgValue: 456.7, byRegion: { EU: 140, US: 172 } }
248
+ // Read the live result — synchronous, O(1)
249
+ const stats = env.views.get('orderStats');
250
+ // → {
251
+ // total: { value: 142500 },
252
+ // count: { value: 312 },
253
+ // avgValue: { value: 456.7 },
254
+ // byRegion: { EU: { value: 140 }, US: { value: 172 } }
255
+ // }
249
256
  ```
250
257
 
258
+ See [docs/views.md](./docs/views.md) for the full reducer reference, `map`, `$ref` sub-aggregations, lifecycle management, and HTTP/MCP surface.
259
+
251
260
  ### 🔑 Authentication & authorization
252
261
 
253
262
  Multi-mode security layer built into the HTTP API. No separate auth service needed.