I am struggling hard to connect to a neon database from a vercel edge function using a prisma client. After searching through the docs, I found out that neon has a serverless driver. I tried to use it how it is specified in the docs:
"use server";
import { Pool, neonConfig } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import { PrismaClient } from "@prisma/client";
import ws from "ws";
export const createPost = async (userId: string, content: string) => {
neonConfig.webSocketConstructor = ws;
const connectionString = `${process.env.DATABASE_URL}`;
const pool = new Pool({ connectionString });
const adapter = new PrismaNeon(pool);
const prisma = new PrismaClient({ adapter });
await prisma.post.create({
data: {
userId: userId,
content: content,
},
});
await prisma.$disconnect();
await pool.end();
};
However, I keep getting this error: SyntaxError: Unexpected identifier 'Promise' at webpack_require. Does anyone know how to resolve this error?
Would love to know if there's a fix for this, struggling with the same error to run Prisma from the edge with the Neon serverless driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With