Need a way to perform count using db.query, or db.select() using db.query args
nvm, I'm an idiot!
/**
* Get the requested data
*/
const results = await db.query[tableName].findMany(queryArgs)
const totalCountQuery = db.select({totalCount: sql`count(*)`}).from(table)
if (queryArgs.where !== undefined) {
totalCountQuery.where( queryArgs.where(table, {or, ilike, eq}))
}
const [{totalCount}] = await totalCountQuery as {totalCount: number}[]/**
* Get the requested data
*/
const results = await db.query[tableName].findMany(queryArgs)
const totalCountQuery = db.select({totalCount: sql`count(*)`}).from(table)
if (queryArgs.where !== undefined) {
totalCountQuery.where( queryArgs.where(table, {or, ilike, eq}))
}
const [{totalCount}] = await totalCountQuery as {totalCount: number}[]