On Mon, Dec 2, 2013 at 9:26 AM, Aymeric Vitte <vitteaymeric@gmail.com>wrote:
> This is about retrieving a large file with partial data and storing it in
> an incremental way in indexedDB.
>
...
> This seems not efficient at all, was it never discussed the possibility to
> be able to append data directly in indexedDB?
>
You're correct, IndexedDB doesn't have a notion of updating part of a
value, or even querying part of a value (other than via indexes). We've
received developer feedback that partial data update and query would both
be valuable, but haven't put significant thought into how it would be
implemented. Conceivably you could imagine an API for "get" or "put" with
an additional keypath into the object. We (Chromium) currently treat the
stored value as opaque so we'd need to deserialize/reserialize the entire
thing anyway unless we added extra smarts in there, at which point a smart
caching layer implemented in JS and tuned for the webapp might be more
effective.
Blobs are pesky since they're not mutable. So even with the above
hand-waved API you'd still be paying for a fetch/concatenate/store. (FWIW,
Chromium's support for Blobs in IndexedDB is still in progress, so this is
all in the abstract.)
I think the best advice at the moment for dealing with incremental data in
IDB is to store the chunks under separate keys, and concatenate when either
all of the data has arrived or lazily on use.