UNPKG

@jadejr/kysely-pglite

Version:

Kysely dialect for @electric-sql/pglite (temporary fork https://github.com/dnlsandiego/kysely-pglite)

27 lines 1.15 kB
import { Kysely } from 'kysely'; import { DatabaseMetadata, EnumCollection, Introspector, TableMatcher, } from 'kysely-codegen'; import { KyselyPGlite } from './kysely-pglite.js'; export class KyselyPGliteIntrospector extends Introspector { async connect(options) { const { dialect } = new KyselyPGlite(); return new Kysely({ dialect }); } async getTables(options) { let tables = await options.db.introspection.getTables(); if (options.includePattern) { const tableMatcher = new TableMatcher(options.includePattern); tables = tables.filter(({ name, schema }) => tableMatcher.match(schema, name)); } if (options.excludePattern) { const tableMatcher = new TableMatcher(options.excludePattern); tables = tables.filter(({ name, schema }) => !tableMatcher.match(schema, name)); } return tables; } async introspect(options) { const tables = await this.getTables(options); const enums = new EnumCollection(); return new DatabaseMetadata({ tables, enums }); } } //# sourceMappingURL=introspector.js.map