This commit is contained in:
Morten Olsen
2025-08-01 07:52:09 +02:00
parent 5782d59f71
commit a25e0b9ffb
17 changed files with 880 additions and 280 deletions

View File

@@ -7,8 +7,10 @@ import type { PostgresDatabase, PostgresRole } from './postgres.types.ts';
class PostgresService {
#db: Knex;
#services: Services;
constructor(services: Services) {
this.#services = services;
const configService = services.get(ConfigService);
const config = configService.postgres;
this.#db = knex({
@@ -22,6 +24,11 @@ class PostgresService {
});
}
public get config() {
const configService = this.#services.get(ConfigService);
return configService.postgres;
}
public upsertRole = async (role: PostgresRole) => {
const existingRole = await this.#db.raw('SELECT 1 FROM pg_roles WHERE rolname = ?', [role.name]);