mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
db: implement asyncDispose
This commit is contained in:
parent
951c145138
commit
f837083146
3 changed files with 6 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ import type { Kysely } from 'kysely';
|
|||
|
||||
import type { DittoTables } from './DittoTables.ts';
|
||||
|
||||
export interface DittoDatabase {
|
||||
export interface DittoDatabase extends AsyncDisposable {
|
||||
readonly kysely: Kysely<DittoTables>;
|
||||
readonly poolSize: number;
|
||||
readonly availableConnections: number;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ export class DittoPglite {
|
|||
poolSize: 1,
|
||||
availableConnections: 1,
|
||||
listen,
|
||||
[Symbol.asyncDispose]: async () => {
|
||||
await pglite.close();
|
||||
await kysely.destroy();
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ export class DittoPostgres {
|
|||
return pg.connections.idle;
|
||||
},
|
||||
listen,
|
||||
[Symbol.asyncDispose]: () => kysely.destroy(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue