I created my indexeddb and it works fine as long as I have app studio open. When I close
app studio, all of the data in the database is removed. How do I keep the data stored permanently?
I am using common and bootstrap4 controls. Are these compatible?
Have you considered using PouchDB instead? It will leverage the underlying browser IndexedDB and will also allow you to replicate the DB contents to a CouchDB instance. You can use this feature to have your app replicate its data to a central server and if the users deletes it and reinstall, the app will heal itself and replicate the data back into the device. It will also keep the data in sync if the users run the app in multiple devices.
In my preferences, deployment is to my local path. I looked into the deployment references in the handbook and they refer to a “picker” in the deployment bar. I am not receiving this picker option or the deployment bar when I open a new project.
I believe selecting “nsbasic server” should be an option that I am not seeing for a new project. Is there a way of activating the deployment bar in a new project or activating the picker option for an existing project? I can fill in the “nsbasic server” in preferences, but I do not have a password for the server. Would this work? Thanks for your help…Joel
While waiting, I decided to try deploying to Volt and selected the demo account first. I got the following message:
I clicked on the first link “Your app” and my app appeared without the Google debugger or some form of Volt dashboard? I loaded the database and the app appeared to operate OK. However, when I left the studio, and came back - same result - the database had lost its data.
I then clicked on the second link and I got the following Create Account Message:
Volt sign on: I tried signing in as an existing user, and got the following email:
However, there was no link to click? Tried several times and got the same
result
Email from Volt:
Click the link below to reset your password: (No link included)
I will send you a copy of my generic indexeddb code shortly…Joel
The following generic code is used to create the indexeddb, and open the existing db. The procedures work when I launch the Desktop Browser, and the database is shown in the Google databases with the data included. The data is lost when I close App Studio, and then restart it.
Below is generic code showing the code structures. My real code is quite lengthy so I thought we could start simple and work up. In the meantime, I will continue to research the Google references for indexed db. I noticed that their “PWA” is currently being updated. Could these changes be effecting my work?
//THIS FUNCTION CREATES THE INDEXEDDB
function DBI10openDB() {
var DBNAME = "name_db"; //1st backup database
var DBVER = 2
var request = indexedDB.open(DBNAME,DBVER);
request.onupgradeneeded = function(e);
UTL0LogIt("Upgrading...");
var thisDB = e.target.result;
var store = null;
if (!thisDB.objectStoreNames.contains(“object1_name”)) {
//bucket for object1_name information
// create objectStore object1_name as keyPath=kpid
var objectStore=thisDB.createObjectStore("object1_name", {keyPath: "kpid"});
objectStore.createIndex('pid', 'pid', {unique: false});
objectStore.createIndex('ps', 'ps', {unique: false});
}
if (!thisDB.objectStoreNames.contains('object2_name')) {
//bucket for object2_name information
// create objectStore object2_name as keyPath=kbyid
var objectStore=thisDB.createObjectStore("object2_name", {keyPath: "kbyid"});
objectStore.createIndex('ey', 'ey', {unique: false});
objectStore.createIndex('cy', 'cy', {unique: false});
objectStore.createIndex('sd', 'sd', {unique: false});
objectStore.createIndex('ed', 'ed', {unique:false});
objectStore.createIndex('dr', 'dr', {unique: false});
}
…several more object stores then
};
request.onsuccess = function(e) {
UTL0LogIt("DBI10openDB success!");
name_db = e.target.result;
UTL0LogIt("this is the db: " + name_db);
};
request.onerror = function(e) {
UTL0LogIt("Database error: " + e.target.errorCode);
};
}
//THIS FUNCTION OPENS THE EXISTING DB
function DBI11openExistingDB() {
var request = indexedDB.open("name_db", 2);
request.onsuccess = function(e) {
name_db = e.target.result;
UTL0LogIt("DBI11openExistingnDB success! ");
UTL0LogIt("this is the name_db: " + name_db);
};
request.onerror = function(event) {
UTL0LogIt("Database error: " + e.target.errorCode);
};
}
Using “Start in Desktop Browser”, I noticed when I deploy, the URL = 127.0.0.1:#####/Project Name/.
As long as I remain in AppStudio the URL does not change. However, if I close AppStudio then reopen AppStudio and deploy again, the ##### part of the URL changes, and the indexeddb is empty of data. Since the page URL has changed so has the page, and it makes sense that the new page would not contain the database information.
When I type in the URL of the previous page, the browser message is that “the web page may be
temporarily down or has moved.”
Once I deploy, is there a way of saving the original URL page?? Thanks…Joel
PS My indexeddb code operated without error for over a year on the previous version of App Studio.