?
db.countDistinct
Count the distinct values of a column, in SQL.
Query.countDistinct(accessor) → Query<number>
Counts the distinct values of one column with SQL COUNT DISTINCT. Use it for cardinality questions, like how many unique respondents or distinct SKUs, without pulling rows to de-duplicate in memory.
Parameters
accessor
(row) => unknown
RequiredThe column whose distinct values are counted.
Count distinct
const respondents = await Answers.countDistinct((a) => a.responseId);