intermediate

Client

Use generated TypeScript queries while understanding selection, inclusion, batching, connection lifecycle, and SQL visibility.

Prisma Client is generated from the schema and exposes typed queries. Production code still needs connection lifecycle management, explicit `select`/`include`, SQL logging, and error handling.

					const orders = await prisma.order.findMany({
  where: { customerId },
  select: { id: true, status: true, total: true },
});
				

On interviews: `select` versus `include`, nested writes, batching behavior, serverless connection pooling, and observing generated SQL.

Common pitfalls: broad `include` graphs; many client instances exhausting connections; assuming types guarantee efficient plans.

The trade-off is developer experience versus query discipline at scale.

Checklist:

  • Select only needed fields.
  • Reuse client lifecycle correctly.
  • Observe SQL and query latency.
  • Map errors to retry or user messages.