一键导入
prisma
// Prisma ORM and PostgreSQL database operations. Use when working with database schema, migrations, queries, or the @projectx/db package.
// Prisma ORM and PostgreSQL database operations. Use when working with database schema, migrations, queries, or the @projectx/db package.
| name | prisma |
| description | Prisma ORM and PostgreSQL database operations. Use when working with database schema, migrations, queries, or the @projectx/db package. |
| allowed-tools | Read, Grep, Glob, Edit, Write, Bash(pnpm:*), Bash(npx prisma:*) |
The Prisma schema and client are in packages/db/.
packages/db/
├── prisma/
│ ├── schema.prisma # Database schema
│ ├── migrations/ # Migration history
│ └── seed.ts # Seed script
└── src/
└── lib/
├── prisma.service.ts # NestJS Prisma service
└── [model]/ # Repository services
└── [model]-repository.service.ts
# Generate Prisma client after schema changes
pnpm prisma:generate
# Create and apply migration (development)
pnpm prisma:migrate:dev
# Apply migrations (production)
pnpm prisma:migrate
# Seed the database
pnpm prisma:seed
# Open Prisma Studio
pnpm --filter @projectx/db exec prisma studio
model Product {
id String @id @default(cuid())
name String
description String?
price Decimal @db.Decimal(10, 2)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relations
categoryId String
category Category @relation(fields: [categoryId], references: [id])
orderItems OrderItem[]
@@index([categoryId])
@@map("products")
}
model Location {
id String @id @default(cuid())
name String
// PostGIS geometry stored as Unsupported type
point Unsupported("geometry(Point, 4326)")
@@map("locations")
}
enum OrderStatus {
PENDING
PROCESSING
SHIPPED
DELIVERED
CANCELLED
}
// packages/db/src/lib/product/product-repository.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma.service';
import { Prisma, Product } from '@prisma/client';
@Injectable()
export class ProductRepositoryService {
constructor(private readonly prisma: PrismaService) {}
async findAll(params?: {
skip?: number;
take?: number;
cursor?: Prisma.ProductWhereUniqueInput;
where?: Prisma.ProductWhereInput;
orderBy?: Prisma.ProductOrderByWithRelationInput;
}): Promise<Product[]> {
return this.prisma.product.findMany(params);
}
async findById(id: string): Promise<Product | null> {
return this.prisma.product.findUnique({
where: { id },
include: { category: true },
});
}
async create(data: Prisma.ProductCreateInput): Promise<Product> {
return this.prisma.product.create({ data });
}
async update(id: string, data: Prisma.ProductUpdateInput): Promise<Product> {
return this.prisma.product.update({
where: { id },
data,
});
}
async delete(id: string): Promise<Product> {
return this.prisma.product.delete({ where: { id } });
}
}
const products = await prisma.product.findMany({
where: {
name: { contains: 'shirt', mode: 'insensitive' },
price: { gte: 10, lte: 100 },
category: { name: 'Clothing' },
},
skip: 0,
take: 20,
orderBy: { createdAt: 'desc' },
include: { category: true },
});
const [order, inventory] = await prisma.$transaction([
prisma.order.create({ data: orderData }),
prisma.inventory.update({
where: { productId },
data: { quantity: { decrement: quantity } },
}),
]);
const nearbyLocations = await prisma.$queryRaw`
SELECT id, name, ST_AsGeoJSON(point) as geojson
FROM locations
WHERE ST_DWithin(
point,
ST_SetSRID(ST_MakePoint(${lng}, ${lat}), 4326)::geography,
${radiusMeters}
)
`;
pnpm prisma:migrate:dev --name descriptive_nameprisma/migrations/pnpm prisma:migrate// packages/db/prisma/seed.ts
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
// Upsert to avoid duplicates
await prisma.category.upsert({
where: { slug: 'electronics' },
update: {},
create: {
name: 'Electronics',
slug: 'electronics',
},
});
}
main()
.catch(console.error)
.finally(() => prisma.$disconnect());
@@map for explicit table namesadd_product_inventory)This skill should be used when the user asks to "create a Temporal workflow", "write a Temporal activity", "debug stuck workflow", "fix non-determinism error", "Temporal TypeScript", "workflow replay", "activity timeout", "signal workflow", "query workflow", "worker not starting", "activity keeps retrying", "Temporal heartbeat", "continue-as-new", "child workflow", "saga pattern", "workflow versioning", "durable execution", "reliable distributed systems", mentions Temporal SDK development or implementing Temporal stuff (workflows, workers, activities), managing queries, updates and signals for existing workflows or updating the configuration for the Temporal worker and clients from our package packages/workflows such as WorkflowsModule, WorkerService, ClientService, or Workflow utils.
Interactive visual playground for designing, editing, and generating Temporal workflows. Use when the user wants to visually build workflows, load existing project workflows onto a canvas, or generate workflow code from a visual spec. Includes its own MCP server (temporal-playground) for chat and connects to temporal-docs MCP for documentation.
NestJS microservices development. Use when creating controllers, services, modules, guards, interceptors, or working with NestJS patterns in auth, order, or product services.
React Router v7 full-stack development with SSR. Use when working with routes, loaders, actions, SSR, Form components, fetchers, navigation guards, protected routes, URL search params, or the web app in apps/web.