Skip to content

Commit

Permalink
Make postgresConnectionOptions optional in PostgresRecordManager
Browse files Browse the repository at this point in the history
Make postgresConnectionOptions optional in PostgresRecordManager to be more in line with PGVectorStore
  • Loading branch information
JonathanVelkeneers authored Jan 24, 2025
1 parent 5bdbb75 commit 265f4a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/langchain-community/src/indexes/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "./base.js";

export type PostgresRecordManagerOptions = {
postgresConnectionOptions: PoolConfig;
postgresConnectionOptions?: PoolConfig;
pool?: Pool;
tableName?: string;
schema?: string;
Expand All @@ -26,7 +26,10 @@ export class PostgresRecordManager implements RecordManagerInterface {
constructor(namespace: string, config: PostgresRecordManagerOptions) {
const { postgresConnectionOptions, tableName, pool } = config;
this.namespace = namespace;
this.pool = pool || new pg.Pool(postgresConnectionOptions);
if (!postgresConnectionOptions && !pool) {
throw new Error("You must provide either a `postgresConnectionOptions` object or a `pool` instance.");
}
this.pool = pool ?? new pg.Pool(postgresConnectionOptions);
this.tableName = tableName || "upsertion_records";
this.finalTableName = config.schema
? `"${config.schema}"."${this.tableName}"`
Expand Down

0 comments on commit 265f4a9

Please sign in to comment.