Skip to content
VibORM
Esc
navigateopen⌘Jpreview

count

Count records matching a filter

Count records matching a filter:

// Count all
const total = await client.user.count();
// Type: number

// Count with filter
const admins = await client.user.count({
  where: { role: "ADMIN" },
});

// Count specific fields (non-null)
const counts = await client.user.count({
  select: {
    _all: true,
    email: true, // Count non-null emails
  },
});
// Type: { _all: number; email: number }

Was this page helpful?