lessquo
lessquo
Explore posts from servers
CDCloudflare Developers
Created by lessquo on 5/15/2024 in #pages-help
Error occurs accessing postgres with drizzle and postgres.js in Remix project
I also tried with node-postgres:
export async function loader({ context }: LoaderFunctionArgs) {
const client = new pg.Client(context.cloudflare.env.DATABASE_URL);
await client.connect();
const db = drizzle(client);
const users = await db.select().from(userTable);
context.cloudflare.ctx.waitUntil(client.end());
return json({ users });
}
export async function loader({ context }: LoaderFunctionArgs) {
const client = new pg.Client(context.cloudflare.env.DATABASE_URL);
await client.connect();
const db = drizzle(client);
const users = await db.select().from(userTable);
context.cloudflare.ctx.waitUntil(client.end());
return json({ users });
}
and it works fortunately. However, it's quite slow (about 800ms). I guess it's because of calling connect and end, causing a roundtrip maybe.
3 replies
CDCloudflare Developers
Created by lessquo on 5/15/2024 in #pages-help
Error occurs accessing postgres with drizzle and postgres.js in Remix project
This issue also reported on postgres GitHub: https://github.com/porsager/postgres/issues/822
3 replies