feat: add PostgreSQL backend
Mirrors the node:sqlite sub-backend structure with full migration support. Uses native pg types (UUID, JSONB, TIMESTAMPTZ) and $1/$2 parameterisation via internal ? placeholders converted at execution time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { GetDbStatic } from "../types/GetDb.js";
|
||||
import { WrappedPool } from "./pool.js";
|
||||
import { PostgresInterface } from "./PostgresInterface.js";
|
||||
import { PostgresMigrator } from "./PostgresMigrator.js";
|
||||
import { isPgUrl, parsePgUrl, pgProtocols } from "./url.js";
|
||||
|
||||
const getPgStatic: GetDbStatic = {
|
||||
name: "postgres",
|
||||
protocols: pgProtocols,
|
||||
checkUrl: isPgUrl,
|
||||
getDbInterface: async (url) => {
|
||||
const { connectionString, readonly } = parsePgUrl(url);
|
||||
return new PostgresInterface(new WrappedPool(connectionString, readonly));
|
||||
},
|
||||
getMigrator: async (url) => {
|
||||
const { connectionString } = parsePgUrl(url);
|
||||
return new PostgresMigrator(new WrappedPool(connectionString));
|
||||
},
|
||||
};
|
||||
export default getPgStatic;
|
||||
Reference in New Issue
Block a user