get<_Model extends T> method
- bool alwaysHydrate = false,
- bool hydrateUnexisting = true,
- bool forceLocalSyncFromRemote = false,
- Query? query,
- bool requireRemote = false,
- bool seedOnly = false,
Load association from SQLite first; if the _Model
hasn't been loaded previously,
fetch it from remoteProvider and hydrate SQLite.
For available query providerArgs see remoteProvider#get
SqliteProvider.get.
alwaysHydrate
ensures data is fetched from the remoteProvider for each invocation.
This often negatively affects performance when enabled. Defaults to false
.
hydrateUnexisting
retrieves from the remoteProvider if the query returns no results from SQLite.
If an empty response can be expected (such as a search page), set to false
. Defaults to true
.
requireRemote
ensures data must be updated from the remoteProvider before returning if the app is online.
An empty array will be returned if the app is offline. Defaults to false
.
seedOnly
does not load data from SQLite after inserting records. Association queries
can be expensive for large datasets, making deserialization a significant hit when the result
is ignorable (e.g. eager loading). Defaults to false
.
Implementation
@override
Future<List<_Model>> get<_Model extends T>({
bool alwaysHydrate = false,
bool hydrateUnexisting = true,
/// When [forceLocalSyncFromRemote] is `true`, local instances that do not exist in the [remoteProvider]
/// are destroyed. Further, when `true`, all values from other parameters except [query] are ignored.
bool forceLocalSyncFromRemote = false,
Query? query,
bool requireRemote = false,
bool seedOnly = false,
}) async {
if (!forceLocalSyncFromRemote) {
return await super.get<_Model>(
alwaysHydrate: alwaysHydrate,
hydrateUnexisting: hydrateUnexisting,
query: query,
requireRemote: requireRemote,
seedOnly: seedOnly,
);
}
return await destructiveLocalSyncFromRemote<_Model>(query: query);
}