Files
evento/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect.js
2026-03-18 14:55:56 -03:00

54 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// <reference types="./postgres-dialect.d.ts" />
import { PostgresDriver } from './postgres-driver.js';
import { PostgresIntrospector } from './postgres-introspector.js';
import { PostgresQueryCompiler } from './postgres-query-compiler.js';
import { PostgresAdapter } from './postgres-adapter.js';
/**
* PostgreSQL dialect that uses the [pg](https://node-postgres.com/) library.
*
* The constructor takes an instance of {@link PostgresDialectConfig}.
*
* ```ts
* import { Pool } from 'pg'
*
* new PostgresDialect({
* pool: new Pool({
* database: 'some_db',
* host: 'localhost',
* })
* })
* ```
*
* If you want the pool to only be created once it's first used, `pool`
* can be a function:
*
* ```ts
* import { Pool } from 'pg'
*
* new PostgresDialect({
* pool: async () => new Pool({
* database: 'some_db',
* host: 'localhost',
* })
* })
* ```
*/
export class PostgresDialect {
#config;
constructor(config) {
this.#config = config;
}
createDriver() {
return new PostgresDriver(this.#config);
}
createQueryCompiler() {
return new PostgresQueryCompiler();
}
createAdapter() {
return new PostgresAdapter();
}
createIntrospector(db) {
return new PostgresIntrospector(db);
}
}