limiting json_agg

Having a bit of a skill issue limiting the amount of data returned from json_agg
const query = ctx.db
.select({
...groupByFilters,
rowCount: sql<number>`count(${schema.returns.id})`.as(
"row_count",
),
data: sql`json_agg(${schema.returns})`,
})
.from(schema.returns)
.groupBy(...Object.values(groupByFilters))
.limit(limit + 1); // limit the amount of groups returned
const query = ctx.db
.select({
...groupByFilters,
rowCount: sql<number>`count(${schema.returns.id})`.as(
"row_count",
),
data: sql`json_agg(${schema.returns})`,
})
.from(schema.returns)
.groupBy(...Object.values(groupByFilters))
.limit(limit + 1); // limit the amount of groups returned
I tried to add a subquery, but I can't seem to get it right
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server