Skip to content

Commit

Permalink
fix(community): Make postgresConnectionOptions optional in PostgresRe…
Browse files Browse the repository at this point in the history
…cordManager (#7580)

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
JonathanVelkeneers and jacoblee93 authored Jan 25, 2025
1 parent 90b06fa commit 4a44ca3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 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,12 @@ 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 4a44ca3

Please sign in to comment.