Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README doesn't properly demonstrate postgres-bridge integration #623

Open
ravinggenius opened this issue Jun 12, 2024 · 0 comments
Open
Labels

Comments

@ravinggenius
Copy link

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. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants