distinct method
Add DISTINCT to the SELECT clause.
Without arguments: SELECT DISTINCT * FROM ... With fields: SELECT DISTINCT ON (field1, field2) ... (PostgreSQL only)
Example:
// Simple DISTINCT
JsonQueryBuilder()
.model('SlotOfAppointment')
.action(QueryAction.findMany)
.distinct()
.selectFields(['startsAt', 'endsAt'])
.build();
// PostgreSQL DISTINCT ON (specific fields)
JsonQueryBuilder()
.model('User')
.action(QueryAction.findMany)
.distinct(['email']) // SELECT DISTINCT ON ("email") *
.build();
Implementation
JsonQueryBuilder distinct([List<String>? fields]) {
_distinct = true;
_distinctFields = fields;
return this;
}