@korajs/store 0.1.0 → 0.1.2

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 +75 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @korajs/store
2
+
3
+ Local storage engine for Kora.js. Supports SQLite WASM with OPFS persistence, IndexedDB fallback, and native SQLite for server-side use. Provides CRUD operations, reactive queries, and subscriptions.
4
+
5
+ > Most developers don't install this directly. Use [`korajs`](https://www.npmjs.com/package/korajs) instead.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @korajs/store
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Create a Store
16
+
17
+ ```typescript
18
+ import { createStore } from '@korajs/store'
19
+ import { defineSchema, t } from '@korajs/core'
20
+
21
+ const schema = defineSchema({
22
+ version: 1,
23
+ collections: {
24
+ todos: {
25
+ fields: {
26
+ title: t.string(),
27
+ completed: t.boolean().default(false),
28
+ createdAt: t.timestamp().auto(),
29
+ },
30
+ },
31
+ },
32
+ })
33
+
34
+ const store = await createStore({ schema, adapter: 'sqlite-wasm' })
35
+ ```
36
+
37
+ ### Insert and Query
38
+
39
+ ```typescript
40
+ await store.insert('todos', { title: 'Ship Kora v1' })
41
+
42
+ const active = await store.query('todos', {
43
+ where: { completed: false },
44
+ orderBy: { createdAt: 'desc' },
45
+ limit: 10,
46
+ })
47
+ ```
48
+
49
+ ### Reactive Subscriptions
50
+
51
+ ```typescript
52
+ const unsubscribe = store.subscribe(
53
+ { collection: 'todos', where: { completed: false }, orderBy: { createdAt: 'asc' } },
54
+ (todos) => {
55
+ // Called immediately with current data, then on every change
56
+ console.log(todos)
57
+ }
58
+ )
59
+ ```
60
+
61
+ ## Storage Adapters
62
+
63
+ | Adapter | Environment | Persistence |
64
+ |---------|-------------|-------------|
65
+ | `sqlite-wasm` | Browser (default) | OPFS |
66
+ | `indexeddb` | Browser (fallback) | IndexedDB |
67
+ | `sqlite-native` | Node.js / Electron | Filesystem |
68
+
69
+ The adapter is selected automatically based on environment. SQLite WASM runs in a Web Worker to avoid blocking the main thread.
70
+
71
+ ## License
72
+
73
+ MIT
74
+
75
+ See the [full documentation](https://github.com/ehoneahobed/kora) for guides, API reference, and examples.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korajs/store",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Kora.js store package",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -63,7 +63,7 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "yjs": "^13.6.30",
66
- "@korajs/core": "0.1.0"
66
+ "@korajs/core": "0.1.2"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@sqlite.org/sqlite-wasm": ">=3.51.0-build1"