Skip to content

@queuert/postgres

const stateAdapter = await createPgStateAdapter({
stateProvider: PgStateProvider, // You implement this
schema?: string, // PostgreSQL schema name (default: "queuert")
tablePrefix?: string, // Table name prefix (default: "")
idType?: string, // SQL type for job IDs (default: "uuid")
idDefault?: string, // SQL DEFAULT expression (default: "gen_random_uuid()")
});

Returns Promise<PgStateAdapter>.

PgStateAdapterStateAdapter extended with migration support:

type PgStateAdapter = StateAdapter & {
migrateToLatest: () => Promise<MigrationResult>;
};

PgStateProvider — you implement this to bridge your PostgreSQL client:

type PgStateProvider<TTxContext> = {
runInTransaction: <T>(fn: (txCtx: TTxContext) => Promise<T>) => Promise<T>;
executeSql: (options: {
txCtx?: TTxContext;
sql: string;
params?: unknown[];
}) => Promise<unknown[]>;
};
const notifyAdapter = await createPgNotifyAdapter({
provider: PgNotifyProvider, // You implement this
channelPrefix?: string, // Channel prefix (default: "queuert")
});

Returns Promise<NotifyAdapter>.

PgNotifyProvider — you implement this to bridge your PostgreSQL client:

type PgNotifyProvider = {
publish: (channel: string, message: string) => Promise<void>;
subscribe: (
channel: string,
onMessage: (message: string) => void,
) => Promise<() => Promise<void>>;
};

pgLiteral — SQL literal escaping. Use when ORMs require raw SQL strings (e.g., Prisma’s $queryRawUnsafe, Drizzle’s sql.raw()):

function pgLiteral(value: unknown): string;
type MigrationResult = {
applied: string[]; // Migrations applied in this run
skipped: string[]; // Already-applied migrations
unrecognized: string[]; // Unknown migrations found in the database
};