Skip to content

Commit 0560f68

Browse files
committed
simplify how to get connectionString (updated 20:55)
1 parent 9396d7c commit 0560f68

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

packages/client/src/client.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export const createClient = (connectionString: string, options: ClientOptions =
105105
}
106106

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

110111
options.applyTypeParsers?.({
@@ -155,12 +156,7 @@ export const createClient = (connectionString: string, options: ClientOptions =
155156
pgp: client,
156157
pgpOptions: options.pgpOptions || {},
157158
...createQueryable(createWrappedQueryFn(client)),
158-
connectionString: () => {
159-
const cn = client.$cn
160-
const result = typeof cn === 'string' ? cn : cn.connectionString
161-
if (!result) throw new Error('Expected connection string')
162-
return result
163-
},
159+
connectionString: () => connectionString,
164160
end: async () => client.$pool.end(),
165161
connect,
166162
transaction: transactionFnFromTask(client),

0 commit comments

Comments
 (0)