From 6d4e2ea0e971798f4b56c236786ebddbf1f63e05 Mon Sep 17 00:00:00 2001
From: WarlaxZ <warlax@hotmail.com>
Date: Tue, 2 Apr 2024 22:07:13 +0100
Subject: [PATCH] fix: dynamic import cjs module pg (#685)

Co-authored-by: Alex Yang <himself65@outlook.com>
---
 packages/core/src/storage/vectorStore/PGVectorStore.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/core/src/storage/vectorStore/PGVectorStore.ts b/packages/core/src/storage/vectorStore/PGVectorStore.ts
index 822c4cc66..74faa5055 100644
--- a/packages/core/src/storage/vectorStore/PGVectorStore.ts
+++ b/packages/core/src/storage/vectorStore/PGVectorStore.ts
@@ -82,7 +82,9 @@ export class PGVectorStore implements VectorStore {
   private async getDb(): Promise<pg.Client> {
     if (!this.db) {
       try {
-        const { Client } = await import("pg");
+        const pg = await import("pg");
+        const { Client } = pg.default ? pg.default : pg;
+
         const { registerType } = await import("pgvector/pg");
         // Create DB connection
         // Read connection params from env - see comment block above
-- 
GitLab