@storion/storion 1.0.2 → 1.0.4

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 +85 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@storion/storion.svg)](https://www.npmjs.com/package/@storion/storion)
6
6
  [![GitHub](https://img.shields.io/badge/GitHub-storionjs%2Fstorion-blue?logo=github)](https://github.com/storionjs/storion)
7
+ [![Documentation](https://storionjs.github.io/storion-docs/)](https://storionjs.github.io/storion-docs/)
7
8
 
8
9
  ---
9
10
 
@@ -12,6 +13,7 @@
12
13
  - [Features](#features)
13
14
  - [Install](#install)
14
15
  - [Quick start](#quick-start)
16
+ - [Common examples](#common-examples)
15
17
  - [Documentation](#documentation)
16
18
  - [Database from config](#database-from-config)
17
19
  - [Query language](#query-language)
@@ -92,6 +94,53 @@ await db.delete('users', 2);
92
94
 
93
95
  ---
94
96
 
97
+ ## Common examples
98
+
99
+ ### Example: simple todo list (localStorage)
100
+
101
+ ```js
102
+ import { createDatabase } from '@storion/storion';
103
+
104
+ const db = await createDatabase({
105
+ name: 'todo-app',
106
+ storage: 'localStorage'
107
+ });
108
+
109
+ await db.createTable('todos', [
110
+ { name: 'id', type: 'int' },
111
+ { name: 'title', type: 'string' },
112
+ { name: 'done', type: 'boolean' }
113
+ ]);
114
+
115
+ // Add a todo
116
+ await db.insert('todos', { title: 'Ship Storion docs', done: false });
117
+
118
+ // Get all open todos
119
+ const openTodos = await db.fetch('todos', {
120
+ filter: { done: false },
121
+ sortBy: 'id'
122
+ });
123
+ ```
124
+
125
+ ### Example: admin-style querying
126
+
127
+ ```js
128
+ // Fetch the 20 latest active users whose name contains "smith"
129
+ const { rows, totalCount } = await db.query('users', {
130
+ where: {
131
+ and: [
132
+ { field: 'active', op: 'eq', value: true },
133
+ { field: 'name', op: 'contains', value: 'smith' }
134
+ ]
135
+ },
136
+ orderBy: [{ field: 'created_at', direction: 'desc' }],
137
+ limit: 20,
138
+ offset: 0
139
+ });
140
+ ```
141
+
142
+ ---
143
+
95
144
  ## Documentation
96
145
 
97
146
  **Documentation:** https://storionjs.github.io/storion-docs/
@@ -266,6 +315,42 @@ const stop = createChangeListener(transport, (event) => {
266
315
  // Later: stop();
267
316
  ```
268
317
 
318
+ ---
319
+
320
+ ## Storion Studio (Chrome extension)
321
+
322
+ **Storion Studio** is a Chrome extension that turns your browser's `localStorage` into a structured database with a visual UI—think of it as an admin console for Storion. It uses the same data layout as the `@storion/storion` npm package, so you can manage data in the extension while your web app uses the library.
323
+
324
+ - **GitHub (extension):** `https://github.com/storionjs/storion-studio`
325
+ - **Docs page:** `https://storionjs.github.io/storion-docs/storion-studio.html`
326
+
327
+ ### What you can do with Studio
328
+
329
+ - Create, delete, and organize multiple databases.
330
+ - Create tables with custom columns and manage schema visually.
331
+ - Insert, read, update, and delete rows in a table grid.
332
+ - Use a Query panel that speaks the same JSON query language as `db.query()`.
333
+ - Export/import databases as JSON.
334
+ - Optionally stream change events to a page that uses Storion (via `postMessage`, Chrome messaging, or other transports).
335
+
336
+ ### Using Studio with your app
337
+
338
+ Because both Studio and the library share the same storage layout (by default under the `__LS_DB__` key in `localStorage`):
339
+
340
+ - You can prototype or inspect data in Storion Studio.
341
+ - Then point your app at the same database with:
342
+
343
+ ```js
344
+ import { createDatabase } from '@storion/storion';
345
+
346
+ const db = await createDatabase({
347
+ name: 'myapp',
348
+ storage: 'localStorage'
349
+ });
350
+ ```
351
+
352
+ If you want live updates from Studio into your app, wire up `setChangeBroadcaster` in the context where Studio is making changes and `createChangeListener` in your app, as shown in the [Cross-context sync](#cross-context-sync-eg-extensions) section.
353
+
269
354
  See [API — createChangeListener](docs/API.md) and [API — setChangeBroadcaster](docs/API.md) for details.
270
355
 
271
356
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storion/storion",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Framework-agnostic client-side database with localStorage, sessionStorage, and IndexedDB. Create databases, tables, save/fetch records, and run JSON queries.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",