indexedDB in a Chrome App

4.7k views Asked by At

I'm building a chrome app which requires a persistent and local database, which in this case can be either indexedDB or basic object storage. I have several questions before i begin developing the app:

  1. Is it possible to persist indexedDB data after un-installation of the chrome app and chrome browser?
  2. If the indexedDB file/data persist can i locate and view it?
  3. If I can locate but can't view it, is it possible to change the location of the indexedDB file?
  4. Can I store the indexedDB in a file located on desktop or any other custom location?
3

There are 3 answers

0
dodtsair On BEST ANSWER

I am writing a basic browser only application. No back end server code at this time. So I also have storage requirements. But I am not doing backup. I am looking at pouchdb as a solution: http://pouchdb.com/

Everything is looking good so far. They also mention that they would work well with Google Apps.

http://pouchdb.com/faq.html#native_support

The nice thing is you could sync your pouchdb data with a server couchdb instance.
http://pouchdb.com/api.html#replication

http://pouchdb.com/api.html#sync

If you want to keep the application local to the browser with no server support you could backup the entire database by using a batch fetch.

http://pouchdb.com/api.html#batch_fetch

I would run the result through gzip before you put it on the filesystem.

3
kzahel On

If I had these requirements, I see a couple of options that you might pursue

  1. Write a simple database backed by the FileSystem API, and periodically lock the database and back up that file. This would be pretty cool because I don't know of anyone who has implemented a simple FileSystem API backed database, but I could see it being useful for other purposes.

  2. Any edits to the database would be also made to a copy of the database stored on your backup server, and I would write functions that could import snapshots from your backup.

  3. Simply write functions to export from your indexedDB to some format into a backup, and to import from the backup.

All options seem quite time consuming. It would be cool if when you create an indexedDB, you could specify an HTML FileSystem API entry file to back it, and that way you wouldn't have to do 1 or 2.

I agree that it seems like quite an oversight that an indexedDB is quite difficult to back up.

2
c0d3rm0nk3y On

I am currently attempting this very same thing. I am using the Chrome Sync File System Api (http://goo.gl/5q8Z9M), but running into some instances where my file (or its contents) is deleted. With this approach I am writing out a JSON object. Hope this helps.