CRUDRepository<TDao extends PrimaryKeyDao<TDao, TPrimaryKey> , TPrimaryKey> class
Repository implementation for basic CRUD operations.
Every operation implemented in CRUDRepository is executed inside its own transaction. When creating methods that are composed of existing operations you may want to execute them inside a single transaction. To do so, wrap the calls that are supposed to be executed inside a single transaction with another transaction call.
Example:
Future<void> composedAction() async {
await transaction((context) {
final entry = await first(...);
await update(entry.copyWith(...));
});
}
- Inheritance
-
- Object
- BaseService
- Repository
- CRUDRepository
Constructors
-
CRUDRepository(String? path, PrimaryKeyDataBean<
TDao, TPrimaryKey> bean)
Properties
-
bean
→ PrimaryKeyDataBean<
TDao, TPrimaryKey> -
final
- configPath → ConfigPath?
-
finalinherited
- environment → Environment
-
Fetch the environment configuration from ConfigService.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
any(
{Filter filter = Filter.empty}) → Future< bool> - Checks if there are any entries that match the filter.
-
config<
T> (String path) → T -
Fetches a configuration value from ConfigService.
inherited
-
configObject<
T extends TransferObjectBase> (String path, TransferBean< T> bean) → T -
Fetches a configuration value from ConfigService and parse it into the
TransferObject.
inherited
-
count(
{Filter filter = Filter.empty}) → Future< int> -
Returns the count of all entries matching the
filter
. -
create(
TDao object) → Future< TPrimaryKey> -
delete(
TDao object) → Future< void> -
deleteAll(
{Filter filter = Filter.empty}) → Future< void> -
deleteById(
TPrimaryKey id) → Future< void> -
exists(
TPrimaryKey id) → Future< bool> - Checks whether or not the id exists.
-
findById(
TPrimaryKey id) → Future< TDao?> -
Returns the object with primary key
id
or null ifid
does not exist. -
first(
{Filter filter = Filter.empty, List< QuerySelect> distinct = const <QuerySelect>[], Sort sort = Sort.empty, int offset = 0}) → Future<TDao?> - Returns the first entry of the query.
-
getAll(
{Filter filter = Filter.empty, Sort sort = Sort.empty, int offset = 0, int limit = -1}) → Future< List< TDao> > -
Returns all entries that match the
filter
. -
initialize(
) → Future< void> -
inherited
-
initializeAdapter(
) → Future< DatabaseAdapter< DatabaseConnection> > -
inherited
-
mutate(
TPrimaryKey id, FutureOr< TDao> mutator(TDao)) → Future<TDao> - Query, modify and update an entry in a single transaction.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shutdown(
) → Future< void> -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
T> (Future< T> delegate(DatabaseContext context)) → Future<T> -
Executes
delegate
inside of a database transaction.inherited -
update(
TDao object) → Future< void>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited