Reference
?

db.groupBy

Group full rows by a key into a Map. Fetches every row.
Query.groupBy(accessor) → Query<Map<K, T[]>>

Groups matching rows by a key and returns a Map of key to the full rows in that group. It fetches every row it groups, so use it only when you need the records themselves; for counts or totals per group, db.aggregate does the reduction in SQL without the fetch.

Parameters
accessor
(row) => K
RequiredThe grouping key.
Group rows
const byStatus = await Vendors.groupBy((v) => v.status);
// Map<status, Vendor[]>