doCountSQL method

  1. @override
FutureOr<int> doCountSQL(
  1. String entityName,
  2. String table,
  3. SQL sql,
  4. Transaction transaction,
  5. DBMySqlConnectionWrapper connection,
)
override

Implementation

@override
FutureOr<int> doCountSQL(String entityName, String table, SQL sql,
    Transaction transaction, DBMySqlConnectionWrapper connection) {
  return connection
      .query(sql.sqlPositional, sql.parametersValuesByPosition)
      .resolveMapped((results) {
    var count = results.map((r) => r.values?.first).firstOrNull ?? 0;
    return count is int ? count : int.tryParse(count.toString().trim()) ?? 0;
  });
}