kobotoolbox / enketo-express

We've moved! Please use the new repository 🠊 https://github.com/enketo/enketo-express
Apache License 2.0
102 stars 90 forks source link

add storage for forms and data [55] #65

Closed MartijnR closed 9 years ago

MartijnR commented 10 years ago

using indexedDb

MartijnR commented 10 years ago

This points estimate is a very big guess.

MartijnR commented 10 years ago
MartijnR commented 10 years ago

https://code.google.com/p/chromium/issues/detail?id=108012

MartijnR commented 10 years ago

confirmed that the issue is still present in beta (39) and dev(40) channel of Chrome. It is not present in Canary ( 41.0.2221.0 ).

Chrome only has blob support for indexeddb since v 37

MartijnR commented 10 years ago

The issue is now also present in Chrome 41.0.2224.3 dev (later version than previous Canary). Wtf? But still not in Canary 41.0.2228.2 canary and 41.0.2229.1 canary. So I guess, Chrome versioning is just confusing for me.

Am carefully optimistic that the Chrome bug with serving media blobs from storage is not present on latest Chrome for Android (Lollipop Dec 5th 2014th). So far so good.

MartijnR commented 10 years ago

Be careful with a solution like localforage that uses multiple storage solutions. A browser update could lead to data loss (e.g. if the preferred indexedDb becomes available).

Also what I don't like about localforage is that you don't get the fancy indexedDb features such as indexing, keyPaths.

MartijnR commented 10 years ago

IE doesn't like blobs to be stored as part of an object. Using simple key, value resolved the issue

MartijnR commented 10 years ago

for Safari, convert Blobs to Base64 and back?? Be prepared for safari adding support in the future, so when retrieving a resource check if it is an instanceof Blob and if not convert to a Blob.

MartijnR commented 10 years ago

arguments against always storing as base64 (dataURI):

arguments for:

MartijnR commented 10 years ago

Database cannot be flushed if another tab is using the same database!

MartijnR commented 9 years ago

Records to do:

MartijnR commented 9 years ago

For posterity:

Storing the record count in the properties table (per form with index YYYp:stats ) and not in the surveys table for the following reasons

  1. Would like to be able to complete remove a cached form but keep the statistics (e.g. as a tool to work around storage bugs it might be useful to remove a form).
  2. Updating a survey recordCounter would otherwise mean retrieving a potentially large survey to read the current counter value and update the whole record with the incremented counter value. Could be a performance issue.
  3. The stats could be extended with other interesting survey info (# of successful submissions, instanceIDs of successful submissions, loading performance, errors)