Persist<T> mixin

The mixin with useful functions to save, update, list, find or delete any model that implements uuid, buildModel and toMap

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
storeRef → StoreRef<String, dynamic>
A pointer to a store.
no setter
uuid String?
Main id that mixin uses to saves, retrieves or deletes in Database.
no setter

Methods

buildModel(Map<String, dynamic> map) → T
Build a new model from a map.
delete() Future<bool>
Deletes a record. Return true if record was deleted or false if record does not exists
dirtyState() → T
Returns a new model with initial state
findById(String id) Future<T?>
Looks in db for model with same id
isDirty([List<Object>? fields]) bool
Returns true if current state is dirty. Optional fields check only if in those fields is dirty.
list({Finder? finder}) Future<List<T>>
List or search items in db
listenChanges() Stream<T>
Emit a event every time has any change in current instance. Will emit a null as last event and closes stream when delete is called
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save([Map<String, dynamic>? overrideData]) Future<T>
Save or update the current state. Return a new instance. The save method do not update current instance.
toMap() Map<String, dynamic>
Must return a Map that represent the current state, that Persist lib will write on db
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

database Future<Database>
Singleton that provides a Database instance
no setter