Skip to main content

Storage

Keep consent and recording state in PostgreSQL, or in PostgreSQL or SQLite through Drizzle.

Part of the API reference for the Consent Ledger LiveKit reference integration.

Store current decisions, receipt references and recording jobs outside application memory. Use PostgreSQL directly, or PostgreSQL or SQLite through Drizzle.


PostgreSQL: consent-ledger-livekit/postgres

Function

Returns

Use it to

postgresSchemaSql({ schema? })

string

Get the SQL that creates the integration's tables (schema version 2; default schema consent_ledger_livekit). Run it as the owner role, not from the application.

createPostgresConsentStore(options)

PostgresConsentStore

Keep current decisions and receipt references in PostgreSQL

createPostgresRecordingJobStore(options)

RecordingJobStore

Keep recording jobs and start records in PostgreSQL

const store = createPostgresConsentStore({
  client: pool, customerId, ledgerId, schema: 'consent_ledger_livekit',
});
const jobs = createPostgresRecordingJobStore({
  client: pool, customerId, ledgerId, schema: 'consent_ledger_livekit',
});
const consent = createConsentClient({ ledger, store });

Both stores take { client, customerId, ledgerId, schema? }. client is anything with query(text, values), such as a pg.Pool. Each store reads and changes only the rows of its customer and ledger. The consent store also has:

Method

Returns

What it does

listReceipts({ sessionId?, participantId?, unresolved? })

Promise<ConsentReceipt[]>

Receipt references, including replaced decisions and ended meetings, oldest first. unresolved: true returns only unconfirmed ones.

listCurrent({ purposeId? })

Promise<ConsentSubmission[]>

Every current decision. Pass the store as the recording controller's decisions.


Drizzle (PostgreSQL and SQLite): consent-ledger-livekit/drizzle

Function

Returns

Use it to

createDrizzleConsentStore(options)

DrizzleConsentStore

Keep current decisions and receipt references through Drizzle. Same methods as PostgresConsentStore, including listReceipts and listCurrent.

createDrizzleRecordingJobStore(options)

RecordingJobStore

Keep recording jobs and start records through Drizzle

consentLedgerMigrations('postgres' | 'sqlite')

{ migrationsFolder, migrationsTable, migrationsSchema? }

Settings for your driver's Drizzle migrate() that apply the integration's migrations, kept apart from yours in __consent_ledger_migrations

postgresTables, createPostgresTables(schema), sqliteTables

Drizzle tables

Read the integration's rows with typed Drizzle queries. Write only through the stores.

Both stores take { db, customerId, ledgerId, schema? }. db is a Drizzle PostgreSQL database (node-postgres, PGlite, postgres.js) or a Drizzle SQLite database on a synchronous driver (better-sqlite3); schema applies to PostgreSQL only. On PostgreSQL, db may also be a Drizzle transaction, so the store's writes commit or roll back with yours.

Did this answer your question?