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
- storeName → String
-
The model name.
no setter
-
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.getter/setter pair
Methods
-
buildModel(
Map< String, dynamic> map) → T -
Build a new model from a
map. -
delete(
) → Future< bool> -
Deletes a record.
Return
trueif record was deleted orfalseif record does not exists -
dirtyState(
) → T - Returns a new model initial state before any change saved.
-
dispose(
) → void - Close the stream controller
-
findById(
String id) → Future< T?> -
Looks in db for model with same
id -
isDirty(
[List< Object> ? fields]) → bool -
Returns
trueif current state is dirty. Optionalfieldscheck 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
nullas last event and closes stream when delete is called -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAfterDelete(
T? data) → void - Hook to run after delete
-
onAfterSave(
T? data) → void - Hook to run after save
-
onBeforeDelete(
T? data) → void - Hook to run before delete
-
onBeforeSave(
T? data, bool update) → void - Hook to run before save
-
refresh(
) → Future< T?> - Refresh current instance with db data.
-
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