3

I'm using the WebDB spec in HTML5 to create an offline database for persistent offline storage. However, I need a way to get the current size of the database from javascript.

The only thing I can think of is to loop through everything in the database, and add the size of all the objects. The only problem is this only works for primitive values, so this would only work if I first serialized all of my javascript objects (using JSON), and seems like a hack.

Is there any better way of doing it? I need accurate numbers.

Thanks for any help

Varun Singh
  • 1,676
  • 3
  • 18
  • 25

1 Answers1

1

Painful solution but what I'm doing is using a size counter in local storage for each table in the DB and wrapping insert, select, update, drop etc. I don't think this will account for sqlite history, but it should provide some way to constrain growth or drop older data as needed.

gwotmcb
  • 11
  • 1