slonik icon indicating copy to clipboard operation
slonik copied to clipboard

README doesn't properly demonstrate `postgres-bridge` integration

Open ravinggenius opened this issue 8 months ago • 0 comments

Expected Behavior

Following instructions in the README, I should be able to integrate with postgres-bridge.

Current Behavior

Following the example in the README causes confusion, as PgPool isn't a valid configuration key. I get the following TypeScript error: "Object literal may only specify known properties, and 'PgPool' does not exist in type 'Partial<ClientConfiguration>. ts(2353)". Furthermore the README for postgres-bridge shows a different way to use it, but not with slonik specifically (as far as I can tell).

Possible Solution

Please show a working example of integrating postgres-bridge with a project that uses slonik.

Steps to Reproduce

  1. checkout my project: https://github.com/ravinggenius/minecraft-tools
  2. install postgres and postgres-bridge
  3. open the file src/services/datastore-service.ts
  4. apply the following diff:
diff --git a/src/services/datastore-service.ts b/src/services/datastore-service.ts
index 32e5716..e176812 100644
--- a/src/services/datastore-service.ts
+++ b/src/services/datastore-service.ts
@@ -1,4 +1,6 @@
 import trim from "cool-trim";
+import postgres from "postgres";
+import { createPostgresBridge } from "postgres-bridge";
 import { createPool, Interceptor, sql } from "slonik";
 import { createQueryLoggingInterceptor } from "slonik-interceptor-query-logging";
 import { createQueryNormalisationInterceptor } from "slonik-interceptor-query-normalisation";
@@ -21,7 +23,8 @@ export const pool = createPool(config.databaseUrl, {
 			? createQueryNormalisationInterceptor()
 			: createQueryTrimInterceptor(),
 		createQueryLoggingInterceptor()
-	]
+	],
+	PgPool: createPostgresBridge(postgres)
 });
 
 export { sql };

Logs

N/A

ravinggenius avatar Jun 12 '24 05:06 ravinggenius