getClient
gets a client from the connection pool.
If all of the pools clients are in-use, it will wait until one is free.
const client = await postgres.getClient()
run
is a utility for quickly getting a client, running a query and releasing the client.
It accepts a previousClient
to be reused instead of creating another.
Whatever is returned from your code is resolved into the promise.
const result = await postgres.run((client) => {
await client.sql`SELECT 1;`
return 'ok'
})
12/11/21 - Upon writing these docs
previousClient
seems a bit pointless, if you already have a client, why call this function?
Optional
previousClient: PostgresClientGenerated using TypeDoc
PostgresService
manages a connection to a postgres database using pools and createsPostgresClient
objects from the pool to talk query the database.