rxfy-server-drizzle
v3.1.1
Published
Drizzle/Postgres storage adapter for rxfy-server
Downloads
384
Readme
rxfy-server-drizzle
Drizzle/Postgres storage adapter for rxfy-server. Binds Drizzle tables to rxfy models and persists the sync server's writes.
Install
npm install rxfy-server-drizzle
# peer deps: rxfy rxfy-server drizzle-orm drizzle-zod zodWhat it gives you
defineResource({ table, name?, model? })— bind a Drizzle table to an rxfy model (derived via drizzle-zod, or pass amodelshared with client code). Returns a storage-neutralResourcecarrying a Drizzle binding, safe to import into client bundles.drizzleStorage(db)— aSyncStoragethat runscreate/update/deleteagainst the bound tables. Pass it tocreateSync.DrizzleBinding— the resource binding type ({ table, pkColumn }).
import { createInMemoryHub, createSync } from "rxfy-server";
import { defineResource, drizzleStorage } from "rxfy-server-drizzle";
const posts = defineResource({ table: postsTable });
const live = createSync({ storage: drizzleStorage(db), hub: createInMemoryHub(), secret });
await live.update(posts, id, { title }); // writes the row and publishes a patchSee the rxfy-server docs for the full walkthrough, and Storage adapters for how this adapter plugs in.
