count method
Count the number of rows that would be returned by the built statement
Implementation
Future<int> count() async {
final countExpression = countAll();
final JoinedSelectStatement statement;
if (joinBuilders.isEmpty) {
statement = buildSelectStatement(targetColumns: [countExpression]);
} else {
final subquery = Subquery(buildSelectStatement(), 'subquery');
statement = db.selectOnly(subquery)..addColumns([countExpression]);
}
return await statement
.map((row) => row.read(countExpression)!)
.get()
.then((value) => value.firstOrNull ?? 0);
}