Kadak

Find Many

Fetch rows with filters, ordering, and limits.

Find Many

Problem: list endpoints can accidentally fetch too many rows.

Solution: use findMany() with $limit and clear filters.

Basic usage

const users = await db.users.findMany({
  isActive: true,
  $limit: 20,
  $order: { createdAt: 'desc' },
})

Operators

const users = await db.users.findMany({
  age: { $gte: 18, $lt: 65 },
  email: { $in: ['a@example.com', 'b@example.com'] },
  $or: [{ role: 'admin' }, { role: 'owner' }],
  $limit: 50,
})

Find first row

const user = await db.users.findFirst({ email: 'riya@example.com' })

Important: always pass $limit unless you explicitly need all rows.

On this page