@rippledb/store-sqlite
v0.2.1
Published
SQLite-based client-side Store for RippleDB with persistent storage.
Downloads
315
Readme
@rippledb/store-sqlite
SQLite-based client-side Store for RippleDB with persistent storage.
📚 Documentation: rippledb.dev/docs/adapters/store-sqlite
Installation
npm install @rippledb/store-sqlite @rippledb/client @rippledb/core better-sqlite3Usage
import { defineSchema, s } from "@rippledb/core";
import { SqliteStore } from "@rippledb/store-sqlite";
const schema = defineSchema({
todos: {
id: s.string(),
title: s.string(),
done: s.boolean(),
},
});
const store = new SqliteStore({
filename: "./data.db",
schema, // Required - creates tables with proper columns
});
// Subscribe to events
const unsubscribe = store.onEvent(event => {
console.log("Change:", event.entity, event.kind, event.id);
});
// Apply changes
await store.applyChanges([change]);
// Query data
const todo = await store.getRow("todos", "todo-1");
const todos = await store.getRows("todos", ["todo-1", "todo-2"]);
// SQL queries with WHERE clauses
const activeTodos = await store.listRows(
"SELECT * FROM todos WHERE done = 0 AND deleted = 0",
);Features
- Implements the
Storeinterface from@rippledb/client - Persistent storage with SQLite
- SQL WHERE clauses on actual columns
- Type-safe: infers schema from descriptor
- Field-level conflict resolution with HLC
License
MIT
