# KyselyPostgres

`class` in `plugin-kysely-postgres` · v0.1.4

<https://docs.seedcord.org/packages/plugin-kysely-postgres/0.1.4/classes/kysely-postgres>

Postgres plugin using Kysely.

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

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

## Constructors

### constructor

```ts
KyselyPostgres(host: CoreBase, options: KyselyOptions)
```

Constructs a new instance of the `KyselyPostgres` class

## Properties

### connection

```ts
public connection: Kysely<KyselySchema>
```

Exposed Kysely instance once `init` completes.

### runtime

```ts
public runtime: 'server'
```

### services

```ts
public get services(): KyselyServices
```

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

### transport

```ts
public transport: 'any'
```

## Methods

### dispose

```ts
public async dispose(): Promise<void>
```

### init

```ts
public async init(): Promise<void>
```

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

Safe to call multiple times, subsequent calls exit early.

### listMigrations

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

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

### listPendingMigrations

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

Lists unapplied migrations.

### migrate

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

Runs migrations using the supplied options.

### migrateDown

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

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

### migrateUp

```ts
public async migrateUp(
    options?: StepMigrationOptions
): Promise<void>
```

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