Help me to keep an encrypted DB accessible for all pages without page.binding


#1

I’m building an app that uses a Sqlcipher database (vanilla js), so the first action when the user opens the app is to type the DB password. Then the login page will send the DB info to the main-view-model.js like this:

page.bindingContext = createViewModel(db);

The createViewModel contains all the other functions to add and select data from the DB, so in order to make this information accessible for all the other pages I need to open the DB again and then page.bidingContext in each one of them. Without doing what it’s in bold I get errors like “db is not defined”.This procedure will work perfectly for a non-encrypted DB, otherwise I’d have to ask the user to type the password each time the app needs to request some info.

So, my intention is to open the DB from the login page, passing the info to the createViewModel function and then make all the necessary calls without having to open it again.


#2

I’m not sure what you’re referencing as being in bold, but when I need to access the data outside data model I often use AppSettings to access local storage and persist data between pages, and even between app invocations. If you’re saving sensitive data you may want to further encrypt it.


#3

I was referring to the sentence in bold “open the db again”. Thanks for your answer. I’ll give it a try.