Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,192
  • Linux
  • Apple
index.ts1.92 kB
import { Prisma, PrismaClient } from './generated/prisma/client' import { PrismaPg } from '@prisma/adapter-pg' import util from 'node:util' async function main() { const prisma = new PrismaClient({ log: ['query'], adapter: new PrismaPg({ connectionString: process.env.TEST_POSTGRES_URI }), }) const email = `user.${Date.now()}@prisma.io` const user = await prisma.user.create({ data: { email }, }) await prisma.post.createMany({ data: [ { title: 'First post', userId: user.id, }, { title: 'Second post', userId: user.id, }, ] }) const query = prisma.user.findMany({ where: { createdAt: { gt: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(), }, }, }) const nestedQuery = await prisma.user.findMany({ include: { posts: true } }) console.log(util.inspect(nestedQuery, { depth: null })) // -------------- // timings // -------------- // warm up native connector await prisma.user.findMany() // console.time('old way') const [, timing] = await benchmark(() => query) // console.timeEnd('old way') console.log('timing', timing) /// -------------- /// misc /// -------------- // console.log( // await newQuery({ // email: 'user.1730130638271@prisma.io', // startDate: new Date(Date.now() - 60 * 60 * 1000).toISOString(), // }), // ) } const benchmark = async <T>(fn: () => Promise<T>): Promise<[result: T, ms: number]> => { const start = process.hrtime.bigint() const result = await fn() const end = process.hrtime.bigint() const ms = Number(end - start) / 1e6 // Duration in milliseconds return [result, ms] } void main() .then(() => { console.log('✅ done') process.exit(0) }) .catch((e) => { console.log('❌ error') console.error(e) process.exit(1) })

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server