GenericModelMap<T extends BaseModel> class

Represents a map of GenericModels with functions to automatically retrieve and save them in a DatabaseRepository

Available Extensions

Constructors

GenericModelMap({required DatabaseRepository repository(), required ModelConstructor<T> supplier, String? defaultDatabaseName})
Maintains a map for the T models with their id as their key.

Properties

defaultDatabaseName String?
Used in the various functions if a databaseName is not specified for them.
final
hashCode int
The hash code for this object.
no setterinherited
map Map<String, T>
The map of BaseModels with their id as the key
final
repository DatabaseRepository Function()
Returns the used DatabaseRepository for the various functions provided.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supplier ModelConstructor<T>
Creates a new instance of T, provided in the constructor
final

Methods

addLoadedModels(Iterable<T> models) → void
Adds the given models to the map without adding them to the repository. It is assumed that these are already present.
addModel(T model, {String? databaseName}) Future<T>
Adds the given model to the map and the given database in repository
deleteModel(T model, {String? databaseName}) Future<bool>
Deletes the given model from the map and the given database in repository
loadAll({String? databaseName}) FutureOr<Iterable<T>>
Loads all of the T models present in repository for the given database.
loadModelIds(Iterable<String> ids, {String? databaseName}) FutureOr<Iterable<T>>
Loads all of the T models with the given ids in repository for the given database.
loadModels(FutureOr<Iterable<T>> loadModels(SpecificDatabase database), {String? databaseName}) FutureOr<Iterable<T>>
Loads models using the given loadModels function and adds them to the map
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeLoadedModels(Iterable<T> models) → void
Removes the given models to the map without removing them from the repository. It is assumed that these have already been removed.
specificDatabase([String? databaseName]) SpecificDatabase
Creates the SpecificDatabase using the defaultDatabaseName passed in the constructor.
toString() String
A string representation of this object.
inherited
updateModel(T model, {String? databaseName}) Future<T>
Updates the given model to the map and the given database in repository

Operators

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