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);
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);
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server