Skip to content

Aggregations & HAVING

const stats = await pulsabase.from(Order)
.select(['status', { count: '*', as: 'total' }])
.groupBy(['status'])
.find();
// [{ status: 'active', total: 42 }, { status: 'pending', total: 8 }]

Filter aggregated results:

const popular = await pulsabase.from(Product)
.select(['category', { count: '*', as: 'total' }])
.groupBy(['category'])
.having({ total: { $gt: 10 } })
.find();
final uniqueCities = await pulsabase.from('users')
.select(['city'])
.distinct()
.find();