Aggregations & HAVING
Group By
Section titled “Group By”const stats = await pulsabase.from(Order) .select(['status', { count: '*', as: 'total' }]) .groupBy(['status']) .find();// [{ status: 'active', total: 42 }, { status: 'pending', total: 8 }]final stats = await pulsabase.from('orders') .select(['status', {'count': '*', 'as': 'total'}]) .groupBy(['status']) .find();HAVING
Section titled “HAVING”Filter aggregated results:
const popular = await pulsabase.from(Product) .select(['category', { count: '*', as: 'total' }]) .groupBy(['category']) .having({ total: { $gt: 10 } }) .find();Distinct
Section titled “Distinct”final uniqueCities = await pulsabase.from('users') .select(['city']) .distinct() .find();