queryCount static method
Creates a 'COUNT' function for the SQL query.
The fields parameter is optional and defaults to ['*']. It should contain the list of fields to count.
The all parameter is optional and defaults to true. If all is true, the method counts all fields. If all is false, the method counts only distinct fields.
This method returns a 'COUNT' function as a string.
Usage:
var count = SqlBuilder.queryCount(fields: ['field1', 'field2'], all: false);
Implementation
static String queryCount(
{List<String> fields = const ['*'], bool all = true}) {
var sentence = '';
if (all) {
sentence = 'COUNT(${fields.join(', ')})';
} else {
sentence = 'COUNT(DISTINCT ${fields.join(', ')})';
}
return sentence;
}