getDatabaseInfo method
Get information about the database.
When offline the a list of the keys in the Lawndart database are returned, otherwise a response for CouchDb is returned.
Implementation
Future<JsonObjectLite<dynamic>> getDatabaseInfo() {
final opCompleter = Completer<JsonObjectLite<dynamic>>();
if (!online) {
_database.lawndart.keys().toList().then((List<dynamic> keys) {
final dynamic res = JsonObjectLite<dynamic>();
res.localResponse = true;
res.operation = dbInfoc;
res.id = null;
res.rev = null;
res.payload = keys;
res.ok = true;
opCompleter.complete(res);
if (_clientCompleter != null) {
_completionResponse = _createCompletionResponse(res);
_clientCompleter();
}
});
} else {
void completer(dynamic res) {
/* If Ok update local storage with the database info */
res.operation = dbInfoc;
res.id = null;
res.rev = null;
res.localResponse = false;
if (!res.error) {
res.ok = true;
res.payload = res.jsonCouchResponse;
} else {
res.localResponse = false;
res.ok = false;
res.payload = null;
}
opCompleter.complete(res);
if (_clientCompleter != null) {
_completionResponse = _createCompletionResponse(res);
_clientCompleter();
}
}
/* Get the database information from CouchDb */
_database.wilt.getDatabaseInfo().then(completer);
}
return opCompleter.future;
}