Skip to main content

Built and signed on GitHub Actions

It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
82%
Published
3 weeks ago (0.1.0)
class PostgresKvStore
implements KvStore

A key-value store that uses PostgreSQL as the underlying storage.

Examples

Example 1

import { createFederation } from "@fedify/fedify";
import { PostgresKvStore } from "@fedify/postgres";
import postgres from "postgres";

const federation = createFederation({
  // ...
  kv: new PostgresKvStore(postgres("postgres://user:pass@localhost/db")),
});

Constructors

new
PostgresKvStore(
sql: Sql<{ }>,
)

Creates a new PostgreSQL key-value store.

Methods

delete(key: KvKey): Promise<void>
drop(): Promise<void>

Drops the table used by the key-value store. Does nothing if the table does not exist.

get<T = unknown>(key: KvKey): Promise<T | undefined>

Creates the table used by the key-value store if it does not already exist. Does nothing if the table already exists.

set(
key: KvKey,
value: unknown,
options?: KvStoreSetOptions | undefined,
): Promise<void>

Add Package

deno add jsr:@fedify/postgres

Import symbol

import { PostgresKvStore } from "@fedify/postgres/kv";

---- OR ----

Import directly with a jsr specifier

import { PostgresKvStore } from "jsr:@fedify/postgres/kv";

Add Package

npx jsr add @fedify/postgres

Import symbol

import { PostgresKvStore } from "@fedify/postgres/kv";

Add Package

yarn dlx jsr add @fedify/postgres

Import symbol

import { PostgresKvStore } from "@fedify/postgres/kv";

Add Package

pnpm dlx jsr add @fedify/postgres

Import symbol

import { PostgresKvStore } from "@fedify/postgres/kv";

Add Package

bunx jsr add @fedify/postgres

Import symbol

import { PostgresKvStore } from "@fedify/postgres/kv";