Skip to content
Classplugin-kysely-postgresv0.8.0

KyselyPostgres

Postgres plugin using Kysely.

Sets up the connection pool, applies migrations, and registers decorated services so the core can resolve them.

class KyselyPostgres extends Plugin<{
    transport: "any";
    runtime: "server";
}>

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the KyselyPostgres class

KyselyPostgres(host: CoreBase, options: KyselyOptions)

connection

Exposed Kysely instance once init completes.

public connection: Kysely<KyselySchema>

core

The host, typed to the transport whose Plugin base this class extends.

protected core: TCore

Inherited from:Plugin

id

public static readonly id

kv

This plugin's records in the bot's config.kv, stored under its attach key. Two attachments of one plugin class each get their own records. Renaming the attach key leaves the records under the old key behind.

protected kv: Kv

Inherited from:Plugin

Throws:

  • A SeedcordTypeError when something built the plugin with new outside attach().

logger

Logs under the plugin's class name, on the channel its attach key sets.

protected readonly logger: Logger

Inherited from:Plugin

services

Map of all services registered with the plugin, keyed by their decorator name.

public get services(): KyselyServices

Throws:

A SeedcordError if accessed before the plugin finishes initializing.

dispose()

public override async dispose(): Promise<void>

init()

Connects to Postgres, runs any startup migrations, and loads decorated services.

Safe to call multiple times, subsequent calls exit early.

public async init(): Promise<void>

listMigrations()

Lists every migration registered with the manager along with its execution state.

public async listMigrations(): Promise<readonly MigrationInfo[]>

listPendingMigrations()

Lists unapplied migrations.

public async listPendingMigrations(): Promise<MigrationInfo[]>

migrate()

Runs migrations using the supplied options.

public async migrate(
    options?: MigrationOptions
): Promise<void>
Parameter: options

Target migration or direction overrides

migrateDown()

Runs a single downwards migration step unless a custom count is provided.

public async migrateDown(
    options?: StepMigrationOptions
): Promise<void>

ready()

Runs in the Ready phase, after every attached plugin's init() has resolved. The other Ready tasks run alongside it, including the http server binding its port.

Override it when your work needs a logged-in client or a resolved application id.

ready?(): Promisable<void>

Inherited from:Plugin

registerCriticalFiles()

Registers critical file patterns that should trigger a full restart when changed in Dev HMR.

protected registerCriticalFiles(
    patterns: string[]
): void
Parameter: patterns

Glob patterns. A relative one resolves against root from seedcord.config.ts.

Inherited from:Plugin

rejectOptions()

Rejects the options this plugin got.

protected rejectOptions(reason: string): never
Parameter: reason

Why the options are invalid.

Throws:

A SeedcordTypeError every time, with the plugin class name and reason in its message.

Inherited from:Plugin