SQLRowCounterDataSource is a TypeScript class that implements
GetDataSource<number> and retrieves counts of rows.
const dataSource = new SQLRowCounterDataSource(sqlDialect, sqlInterface, 'employee');// Counting total number of rowsconst totalCount = await dataSource.get(new VoidQuery());// Counting employees of age 18const count = await dataSource.get(new AgeQuery(18));
This class only implements the
get method, as
getAll throws a
To count rows, we need to support the following two query types:
Subclasses will define the exact configuration of each action.
Customization of select statement
RawSQLDataSource use the
selectSQL method to override the select statement.
SQLRowCounterDataSource supports soft deletion of rows counting. To enable it, just call the
SQLRowCounterDataSource constructor passing the option
true in the softDeleteEnabled option, as well as the name of the column used to store