How to get count with main query

Hi. Can i combine these two queries?
const data = await db
  .select({ id: S.appointment.id })
  .from(S.appointment)
  .orderBy(desc(S.appointment.createdAt))
  .limit(perPage)
  .offset(perPage * (page - 1));

const resultCount = await db.select({ value: count() }).from(S.appointment);
Was this page helpful?