Packages
Memory Postgres
Public exports from @anvia/memory-postgres.
Import from @anvia/memory-postgres.
createPostgresMemoryStore
async function createPostgresMemoryStore(
options?: PostgresMemoryStoreOptions,
): Promise<PostgresMemoryStore>;
Purpose: create a Postgres-backed core MemoryStore.
Return behavior: creates tables by default, or uses existing tables when createIfMissing: false is set.
PostgresMemoryStore
class PostgresMemoryStore {
static connect(options?: PostgresMemoryStoreOptions): Promise<PostgresMemoryStore>;
load(context: PostgresMemoryContext): Promise<Message[]>;
append(input: PostgresMemoryAppendInput): Promise<void>;
clear(context: PostgresMemoryContext): Promise<void>;
recordError(input: PostgresMemoryErrorInput): Promise<void>;
}
Purpose: implementation of the Anvia MemoryStore contract backed by Postgres tables.
Return behavior: append and failed-run writes run inside a transaction and use advisory locking by default.
createPostgresMemorySchemaSql
function createPostgresMemorySchemaSql(
options?: PostgresMemorySchemaOptions,
): string;
Purpose: return SQL for the required Postgres tables and indexes.
createPostgresMemoryScopeKey
function createPostgresMemoryScopeKey(
context: PostgresMemoryContext,
options?: PostgresMemoryScopeOptions,
): string;
Purpose: convert sessionId, optional userId, and selected metadata keys into a stable database scope key.
Options And Client Types
type PostgresMemoryErrorMode = "store" | "ignore";
type PostgresMemoryLockMode = "advisory" | "none";
type PostgresMemoryTableNames = {
sessions?: string;
messages?: string;
errors?: string;
};
type PostgresMemorySchemaOptions = {
tablePrefix?: string;
tableNames?: PostgresMemoryTableNames;
};
type PostgresMemoryStoreOptions = PostgresMemorySchemaOptions & {
client?: PostgresMemoryClientLike;
connectionString?: string;
createIfMissing?: boolean;
scope?: PostgresMemoryScopeOptions | ((context: PostgresMemoryContext) => string);
errors?: PostgresMemoryErrorMode;
validateMessages?: boolean;
lock?: PostgresMemoryLockMode;
};
Purpose: configure connection, schema names, table creation, scope generation, failed-run storage, validation, and advisory locking.
Related exported aliases: PostgresMemoryAppendInput, PostgresMemoryClientLike, PostgresMemoryContext, PostgresMemoryErrorInput, PostgresMemoryPoolLike, PostgresMemoryQueryResult, PostgresMemoryScopeOptions, and PostgresMemoryTransactionClientLike.
