Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this still necessary? #2

Open
manuganji opened this issue Aug 24, 2023 · 0 comments
Open

Is this still necessary? #2

manuganji opened this issue Aug 24, 2023 · 0 comments

Comments

@manuganji
Copy link

I'm using @vercel/postgres to create pool and pass a client to run function. Won't this be enough?

Steps to reproduce

import { createPool, VercelPool } from '@vercel/postgres';

let pool: VercelPool;

export async function getPool() {
	if (!pool) {
		pool = createPool({
			connectionString: DATABASE_URL
		});
	}
	return await pool.connect();
}

export async function runQuery<T>(query: SQLFragment<T>) {
	const client = await getPool();
	const res = await query.run(client);
	client.release();
	return res;
}

Expected result

It works without issues on Vercel

Actual result

Environment

Vercel

Logs, links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant