FakeDatabaseRepository class

A DatabaseRepository that stores everything in memory

This is best used in unit tests

Inheritance

Constructors

FakeDatabaseRepository({required Map<Type, ModelConstructor<BaseModel>> constructors})
constructors holds all of the ModelConstructors that can be found in this repository.

Properties

channel ↔ BlocEventChannel
This is shared between all Repositorys in the repository layer.
latefinalinherited
constructors Map<Type, ModelConstructor<BaseModel>>
constructors holds all of the ModelConstructors that can be found in this repository.
final
errorStream StreamController<DatabaseException>
Listen for DatabaseExceptions that occur from trying to access this database.
latefinalinherited
fakeDatabaseMap Map<String, Map<String, BaseModel>>
The "Storage" of this database
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

containsRows<T extends BaseModel>(String database, T supplier()) FutureOr<bool>
Returns true if the table/container in database contains any data with same type provided by supplier
inherited
deleteModel<T extends BaseModel>(String database, T model) bool
Deletes the T model in database. model doesn not need to be exactly the same, just have the same id.
override
dispose() → void
Disposes this value to save memory. Implementations should be idempotent.
inherited
findAllModelsOfType<T extends BaseModel>(String database, T supplier()) Iterable<T>
This functions finds all models of the given type that have their BaseModel.id start with the prefix given by the suppliers BaseModelIDExtension.prefixTypeForId
override
findModel<T extends BaseModel>(String database, String key) → T?
Finds the T model in database with id of key.
override
findModels<T extends BaseModel>(String database, Iterable<String> keys) FutureOr<Iterable<T>>
Finds all the models in the given database that have the given keys
inherited
generateListeners(BlocEventChannel channel) List<BlocEventListener>
Generates the listener map that this Repository will remove from the channel when this repository is disposed.
getInstance<T>() → T
Creates an instance using one of the constructors
getMap(String database) Map<String, BaseModel>
Gets the "Storage" map for the given database
initialize(BlocEventChannel channel) → void
Initializes this repository, adding the listeners produced by generateListeners to the given channel.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
saveModel<T extends BaseModel>(String database, T model) → T
Saves the T model in database. models that do not have an existing id will have one automatically assigned to them. This function doesn't care if there is an already existing model or not. Existing models will just be overridden
override
saveModels<T extends BaseModel>(String database, Iterable<T> models) FutureOr<void>
Saves the T models in database. models that do not have an existing id will have one automatically assigned to them. This function doesn't care if there is an already existing model or not. Existing models will just be overridden
inherited
searchByModelAndFields<T extends BaseModel>(String database, T supplier(), T model, List<String> fields) FutureOr<Iterable<T>>
Finds all models in database that have values that match the passed model's values
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited