FakeDatabaseRepository class
A DatabaseRepository that stores everything in memory
This is best used in unit tests
- Inheritance
-
- Object
- DatabaseRepository
- FakeDatabaseRepository
Constructors
-
FakeDatabaseRepository({required Map<
Type, ModelConstructor< constructors})BaseModel> > - constructors holds all of the ModelConstructors that can be found in this repository.
Properties
- channel ↔ BlocEventChannel
-
This is shared between all
Repository
s in the repository layer.latefinalinherited -
constructors
→ Map<
Type, ModelConstructor< BaseModel> > -
constructors holds all of the
ModelConstructor
s that can be found in this repository.final -
errorStream
→ StreamController<
DatabaseException> -
Listen for
DatabaseException
s 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 bysupplier
inherited -
deleteModel<
T extends BaseModel> (String database, T model) → bool -
Deletes the
T
model
indatabase
.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
supplier
s BaseModelIDExtension.prefixTypeForIdoverride -
findModel<
T extends BaseModel> (String database, String key) → T? -
Finds the
T
model indatabase
with id ofkey
.override -
findModels<
T extends BaseModel> (String database, Iterable< String> keys) → FutureOr<Iterable< T> > -
Finds all the models in the given
database
that have the givenkeys
inherited -
generateListeners(
BlocEventChannel channel) → List< BlocEventListener> -
Generates the listener map that this
Repository
will remove from thechannel
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
indatabase
.model
s 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 overriddenoverride -
saveModels<
T extends BaseModel> (String database, Iterable< T> models) → FutureOr<void> -
Saves the
T
models
indatabase
.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 overriddeninherited -
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 passedmodel
's valuesinherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited