I am having a problem with putting a document to the local database.
The code I use is as follows:
var localDB = new PouchDB("db_local", {auto_compaction: true});
localDB.put(poi, function callback(err) {
if (!err) {
if (networkState == Connection.NONE || navigator.onLine == false)
navigator.notification.alert(i18n.t("messages.contributionSuccessNoInternet"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
else
navigator.notification.alert(i18n.t("messages.contributionSuccess"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
}
else {
navigator.notification.alert(i18n.t("messages.errorStorage"), null, "Land Cover Collector", i18n.t("messages.ok"));
remotePointsDB.put(poi, function callback(err) {
if (!err)
navigator.notification.alert(i18n.t("messages.contributionSuccess"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
else
navigator.notification.alert(i18n.t("messages.error") + " " + err, null, "Land Cover Collector", i18n.t("messages.ok"));
});
}
});
Strangely not of the alerts are happening, and this happens on only one device I have. I am using Chrome browser, and compiling the code for Android with Cordova. The device has few free storage. Can anyone guess what can be the reason?
EDIT:
localDB.put(poi, function callback(err, response) {
if (!err)
alert("local success");
else
alert("local: " + err);
});
remotePointsDB.put(poi, function callback(err, response) {
if (!err)
alert("remote success");
else
alert("remote: " + err);
});