move count to base table manager

This commit is contained in:
Moshe Dicker 2024-04-17 12:23:21 -04:00
parent 270f8d2a49
commit 22ec0f77a6
1 changed files with 6 additions and 6 deletions

View File

@ -342,6 +342,12 @@ abstract class BaseTableManager<
/// supports setting fields back to null.
Future<int> update(Insertable<DT> Function(CU o) f) =>
$state.buildUpdateStatement().write(f($state._getUpdateCompanionBuilder));
/// Return the count of rows matched by the built statement
/// When counting rows, the query will only count distinct rows by default
Future<int> count([bool distinct = true]) {
return $state.copyWith(distinct: true).count();
}
}
/// A table manager that can be used to select rows from a table
@ -362,12 +368,6 @@ abstract class ProcessedTableManager<
/// Create a new [ProcessedTableManager] instance
const ProcessedTableManager(super.$state);
/// Return the count of rows matched by the built statement
/// When counting rows, the query will only count distinct rows by default
Future<int> count([bool distinct = true]) {
return $state.copyWith(distinct: true).count();
}
/// Checks whether any rows exist
Future<bool> exists() => $state.exists();