@ddsm/ledger-postgres
v0.2.0
Published
Postgres-backed LedgerAdapter for DDSM reconciliation entries
Downloads
98
Readme
@ddsm/ledger-postgres
PostgreSQL-backed LedgerAdapter for the DDSM processor. Append-only, CID-indexed entry store with sequence-based pull replication.
Install
npm install @ddsm/ledger-postgresUsage
import { PostgresLedgerAdapter } from "@ddsm/ledger-postgres";
import { DDSMProcessor } from "@ddsm/processor";
const ledger = new PostgresLedgerAdapter({
connectionString: process.env.POSTGRES_URL,
});
const processor = new DDSMProcessor({ did, signer, ledger, manifestUrl });Schema migration
The adapter ships a schema SQL file. Apply it once before first use:
import { createRequire } from "node:module";
import fs from "node:fs";
const require = createRequire(import.meta.url);
const sql = fs.readFileSync(
require.resolve("@ddsm/ledger-postgres/src/schema.sql"),
"utf-8"
);
await pgClient.query(sql);This creates the ddsm schema with ddsm.ledger_entries and ddsm.ledger_sequence, isolated from your application's tables.
Packages
| Package | Description | |---|---| | @ddsm/core | Protocol types and pure functions | | @ddsm/processor | Stateful processor, signing, reconciliation | | @ddsm/ledger-postgres | This package | | @ddsm/cli | CLI / REPL |
