Skip to main content

group_by

Macro group_by 

Source
group_by!() { /* proc-macro */ }
Expand description

prax::group_by! — schema-aware DSL targeting group_by_columns. Accepts by: (required), where:, _count:, _sum:, _avg:, _min:, _max:, having:, and order_by: keys. order_by: sorts groups by a by: column (order_by: { team_id: asc }) or by a selected aggregate (order_by: { _sum: { views: desc } }).

prax::group_by!(client.user, {
    by: [team_id, region],
    where: { active: true },
    _count: { _all: true },
    _sum: { views: true },
    having: { _count: { _all: { gt: 5 } } },
    order_by: { _sum: { views: desc } },
});