Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@types/node": "20.12.8",
"@types/react": "18.3.1",
"@upstash/redis": "^1.28.4",
"@vercel/functions": "^1.0.1",
"@vercel/kv": "^1.0.1",
"@vercel/postgres": "^0.8.0",
"@xata.io/client": "^0.29.4",
Expand Down
12 changes: 9 additions & 3 deletions pages/api/neon-prisma-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@ import { NextRequest as Request, NextResponse as Response } from "next/server";
import { Pool } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@/prisma-neon/prisma-client'
import { waitUntil } from "@vercel/functions";

export const config = {
runtime: "edge",
};
const pool = new Pool({ connectionString: process.env.NEON_DATABASE_URL, idleTimeoutMillis: 1 })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })

const start = Date.now()

export default async function api(req: Request) {
const count = toNumber(new URL(req.url).searchParams.get("count"));
const time = Date.now();

const pool = new Pool({ connectionString: process.env.NEON_DATABASE_URL })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })

let data = null;
for (let i = 0; i < count; i++) {

data = await prisma.employees.findMany({ take: 10 });
}

waitUntil(pool.end());

return Response.json(
{
data,
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.