Loading...
Loading...
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
npx skill4agent add prisma/skills prisma-client-apiimport { PrismaClient } from '../generated/client'
import { PrismaPg } from '@prisma/adapter-pg'
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL
})
const prisma = new PrismaClient({ adapter })| Method | Description |
|---|---|
| Find one record by unique field |
| Find one or throw error |
| Find first matching record |
| Find first or throw error |
| Find multiple records |
| Create a new record |
| Create multiple records |
| Create multiple and return them |
| Update one record |
| Update multiple records |
| Update multiple and return them |
| Update or create record |
| Delete one record |
| Delete multiple records |
| Count matching records |
| Aggregate values (sum, avg, etc.) |
| Group and aggregate |
| Option | Description |
|---|---|
| Filter conditions |
| Fields to include |
| Relations to load |
| Fields to exclude |
| Sort order |
| Limit results |
| Skip results (pagination) |
| Cursor-based pagination |
| Unique values only |
| Method | Description |
|---|---|
| Explicitly connect to database |
| Disconnect from database |
| Execute transaction |
| Execute raw SQL query |
| Execute raw SQL command |
| Subscribe to events |
| Add extensions |
// Find by unique field
const user = await prisma.user.findUnique({
where: { email: 'alice@prisma.io' }
})
// Find with filter
const users = await prisma.user.findMany({
where: { role: 'ADMIN' },
orderBy: { createdAt: 'desc' },
take: 10
})const user = await prisma.user.create({
data: {
email: 'alice@prisma.io',
name: 'Alice',
posts: {
create: { title: 'Hello World' }
}
},
include: { posts: true }
})const user = await prisma.user.update({
where: { id: 1 },
data: { name: 'Alice Smith' }
})await prisma.user.delete({
where: { id: 1 }
})const [user, post] = await prisma.$transaction([
prisma.user.create({ data: { email: 'alice@prisma.io' } }),
prisma.post.create({ data: { title: 'Hello', authorId: 1 } })
])rules/constructor.md - PrismaClient constructor options
rules/model-queries.md - CRUD operations
rules/query-options.md - select, include, omit, where, orderBy
rules/filters.md - Filter conditions and operators
rules/relations.md - Relation queries and nested operations
rules/transactions.md - Transaction API
rules/raw-queries.md - $queryRaw, $executeRaw
rules/client-methods.md - $connect, $disconnect, $on, $extends| Operator | Description |
|---|---|
| Exact match |
| Not equal |
| In array |
| Not in array |
| Less than |
| Greater than |
| String contains |
| String starts with |
| String ends with |
| Case sensitivity |
| Operator | Description |
|---|---|
| At least one related record matches |
| All related records match |
| No related records match |
| Related record matches (1-to-1) |
| Related record doesn't match |