prisma-queries
This skill should be used when the user asks about "prisma client", "findMany", "findUnique", "create", "update", "delete", "prisma query", "include", "select", "where", "prisma transactions", "nested writes", or mentions database queries and CRUD operations with Prisma.
What this skill does
# Prisma Queries
Query and mutate data using Prisma Client with type-safe operations.
## Client Setup
```typescript
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
// With logging
const prisma = new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
})
```
## CRUD Operations
### Create
```typescript
// Create single record
const user = await prisma.user.create({
data: {
email: '[email protected]',
name: 'Alice',
},
})
// Create many
const count = await prisma.user.createMany({
data: [
{ email: '[email protected]' },
{ email: '[email protected]' },
],
skipDuplicates: true,
})
```
### Read
```typescript
// Find unique (by unique field)
const user = await prisma.user.findUnique({
where: { email: '[email protected]' },
})
// Find first matching
const user = await prisma.user.findFirst({
where: { name: { contains: 'Alice' } },
})
// Find many
const users = await prisma.user.findMany({
where: { role: 'ADMIN' },
orderBy: { createdAt: 'desc' },
take: 10,
skip: 0,
})
// Find or throw
const user = await prisma.user.findUniqueOrThrow({
where: { id: 1 },
})
```
### Update
```typescript
// Update single
const user = await prisma.user.update({
where: { id: 1 },
data: { name: 'New Name' },
})
// Upsert (update or create)
const user = await prisma.user.upsert({
where: { email: '[email protected]' },
update: { name: 'Alice Updated' },
create: { email: '[email protected]', name: 'Alice' },
})
```
### Delete
```typescript
// Delete single
const user = await prisma.user.delete({
where: { id: 1 },
})
// Delete many
const count = await prisma.user.deleteMany({
where: { verified: false },
})
```
## Filtering
### Basic Filters
```typescript
const users = await prisma.user.findMany({
where: {
email: '[email protected]', // Exact match
name: { contains: 'Ali' }, // Contains
age: { gte: 18 }, // Greater than or equal
role: { in: ['ADMIN', 'MOD'] }, // In list
verified: { not: false }, // Not equal
},
})
```
### Filter Operators
| Operator | Description |
|----------|-------------|
| `equals` | Exact match |
| `not` | Not equal |
| `in` | In array |
| `notIn` | Not in array |
| `lt`, `lte` | Less than (or equal) |
| `gt`, `gte` | Greater than (or equal) |
| `contains` | String contains |
| `startsWith` | String starts with |
| `endsWith` | String ends with |
| `mode: 'insensitive'` | Case-insensitive |
## Select and Include
### Select Specific Fields
```typescript
const users = await prisma.user.findMany({
select: {
id: true,
email: true,
// Only these fields returned
},
})
```
### Include Relations
```typescript
const user = await prisma.user.findUnique({
where: { id: 1 },
include: {
posts: true, // All posts
profile: true, // Profile relation
},
})
```
## Pagination
```typescript
// Offset pagination
const users = await prisma.user.findMany({
skip: 20,
take: 10,
orderBy: { createdAt: 'desc' },
})
// Cursor pagination
const users = await prisma.user.findMany({
take: 10,
cursor: { id: lastUserId },
orderBy: { id: 'asc' },
})
```
## Advanced Operations
For complex query patterns beyond basic CRUD, see [references/advanced-queries.md](references/advanced-queries.md):
| Topic | Use When |
|-------|----------|
| Combining Filters | Building complex AND/OR/NOT conditions |
| Relation Filters | Filtering by related record properties |
| Nested Includes | Loading deeply nested or filtered relations |
| Aggregations | count, sum, avg, min, max, groupBy |
| Transactions | Multi-operation atomicity (sequential or interactive) |
| Nested Writes | Creating/updating related records in one call |
| Raw Queries | Complex SQL the Prisma Client can't express |
## Best Practices
1. **Use `select` to limit fields** - Reduce payload size
2. **Paginate large results** - Use `take` and `skip`/`cursor`
3. **Use transactions for consistency** - Multiple related operations
4. **Handle errors gracefully** - Catch Prisma errors by code
5. **Disconnect on shutdown** - Call `prisma.$disconnect()`
## Reference Files
| File | Contents |
|------|----------|
| [references/advanced-queries.md](references/advanced-queries.md) | Combining filters, relation filters, nested includes, aggregations, transactions, nested writes, raw queries |
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.