1

I have an offline web app for PC with JavaScript and I am looking to add a database to it. The problem is that it requires persistent data storage across multiple computers (via USB). So I want to find a way to store this data on a USB instead of on the computer's hard drive.

I have looked into solutions such as lokijs and while lokijs does have persistent storage, it is stored inside Local Storage or IndexedDB. This means that it is stored on the computer through the browser. A way to solve this is to somehow read/write files with JavaScript or to save the database file in the same directory as the other files (for portability through USB). Is there a way to do this? To my knowledge, there isn't a way to achieve this.

Another solution would be to download a portable version of Chrome and create a .bat file to ensure that the web app will open using the portable Chrome. I think (not too sure) that the portable Chrome will keep the Local Storage/IndexedDB data in between sessions. However, this method is bulky and I would rather not rely on this.

So, is there an alternative to solve this problem? Or is there another JavaScript database out there that can locally store and retrieve a database to achieve persistent data storage across multiple computers via USB.

Thanks for reading and I'd appreciate any answers.

K. Ngo
  • 13
  • 2

2 Answers2

2

Javascript doesn't have access to your disks - for security reasons. You can't read/write to a local drive using a web app, otherwise it would be much easier for malware to spread. That's why solutions like lokijs use in-browser storage. If you want an offline app with portable storage that can run from USB I would be looking at a rewrite using a different technology / programming language. If it needs to be cross-platform as well, Java is probably your best bet.

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • Thanks for your answer and suggestion. I'll definitely look into other technologies as you and meskobalazs suggested. – K. Ngo Jun 07 '16 at 11:22
0

Basically, you want a portable, fat-client application built with web technologies. There are multiple solutions for this. I'd recommend using NodeWebKit or something similar (JavaFX also has web rendering capabilities with JavaScript).

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
  • Thanks for your answer and suggestion. If you don't mind, what is your opinion about [Electron](http://electron.atom.io/) vs the [NW.js](http://nwjs.io/) you mentioned? – K. Ngo Jun 07 '16 at 11:32
  • I don't really know it, but it definitely worth a look. – meskobalazs Jun 07 '16 at 11:46