Adapters
store-memory
In-memory Store implementation for tests and examples
@rippledb/store-memory
An in-memory implementation of the Store contract from @rippledb/client. Useful for tests, examples, and quick prototypes.
This store does not persist anything. For production apps, you'll want a
persistent store-* implementation like
store-sqlite (or IndexedDB in the future).
Installation
pnpm add @rippledb/store-memorynpm install @rippledb/store-memoryyarn add @rippledb/store-memoryBasic Usage
import { MemoryStore } from "@rippledb/store-memory";
import { makeUpsert } from "@rippledb/core";
type Schema = {
todos: { id: string; title: string; done?: boolean };
};
const store = new MemoryStore<Schema>();
// Subscribe to reactivity events (optional)
store.onEvent((ev) => {
console.log(ev); // { entity, kind, id? }
});
// Apply changes transactionally
await store.applyChanges([
makeUpsert({
stream: "demo",
entity: "todos",
entityId: "todo-1",
patch: { id: "todo-1", title: "Buy milk", done: false },
}),
]);
// Read a single row
const todo = await store.getRow("todos", "todo-1");
// List rows (query shape is store-specific)
const todos = await store.listRows({ entity: "todos" });Query Shape
store-memory supports a simple list query:
type MemoryListQuery = { entity: string };