get<_Model extends OfflineFirstWithRestModel> method
- Query? query,
- bool alwaysHydrate = false,
- bool hydrateUnexisting = true,
- 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 OfflineFirstWithRestModel>({
query,
bool alwaysHydrate = false,
bool hydrateUnexisting = true,
bool requireRemote = false,
bool seedOnly = false,
}) async {
try {
return await super.get(
query: query,
alwaysHydrate: alwaysHydrate,
hydrateUnexisting: hydrateUnexisting,
requireRemote: requireRemote,
seedOnly: seedOnly,
);
} on RestException catch (e) {
logger.warning('#get rest failure: $e');
if (_ignoreTunnelException(e)) {
return <_Model>[];
}
throw OfflineFirstException(e);
}
}