Skip to content

Commit

Permalink
simplify how to get connectionString (updated 20:55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Sep 13, 2024
1 parent 9396d7c commit 0560f68
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const createClient = (connectionString: string, options: ClientOptions =
}

const types = new TypeOverrides()
// note: this should be done "high up" in the app: https://stackoverflow.com/questions/34382796/where-should-i-initialize-pg-promise
const pgp = pgPromise(options.pgpOptions?.initialize)

options.applyTypeParsers?.({
Expand Down Expand Up @@ -155,12 +156,7 @@ export const createClient = (connectionString: string, options: ClientOptions =
pgp: client,
pgpOptions: options.pgpOptions || {},
...createQueryable(createWrappedQueryFn(client)),
connectionString: () => {
const cn = client.$cn
const result = typeof cn === 'string' ? cn : cn.connectionString
if (!result) throw new Error('Expected connection string')
return result
},
connectionString: () => connectionString,
end: async () => client.$pool.end(),
connect,
transaction: transactionFnFromTask(client),
Expand Down

0 comments on commit 0560f68

Please sign in to comment.