Neon Transaction Support with drizzle in cloudflare workers
Hi, I am trying to make a db transaction using drizzle orm in cloudlfare workers using NeonDB. I am using the neon function as client which is imported from @neondatabase/serverless module. When I make an api request, it returns me an error saying:
"No transactions support in neon-http driver".
Can someone help me with this?
Note: This is happening only with transactions, not with insert or query
1 Reply
fascinating-indigo•2y ago
Hey, the Neon serverless driver supports connections over HTTP and connections over WebSockets. For interactive transaction support, you have to connect over WebSockets using the Pool or Client constructors:
https://github.com/neondatabase/serverless?tab=readme-ov-file#pool-and-client
The transaction() function for queries over HTTP is for batched single-shot queries (the naming is a bit confusing). See:
https://github.com/neondatabase/serverless/blob/main/CONFIG.md#transaction-function
GitHub
serverless/CONFIG.md at main · neondatabase/serverless
Connect to Neon PostgreSQL from serverless/worker/edge functions - neondatabase/serverless
GitHub
GitHub - neondatabase/serverless: Connect to Neon PostgreSQL from s...
Connect to Neon PostgreSQL from serverless/worker/edge functions - neondatabase/serverless