Re: [IndexedDB] Need a method to clear an object store
On Wed, Aug 4, 2010 at 10:35 AM, Pablo Castro pablo.cas...@microsoft.com wrote: From: public-webapps-requ...@w3.org [mailto:public-webapps-requ...@w3.org] On Behalf Of Jonas Sicking Sent: Tuesday, August 03, 2010 12:21 PM On Tue, Aug 3, 2010 at 12:09 PM, ben turner bent.mozi...@gmail.com wrote: Hi folks, Currently there are only two ways to clear an object store of all data: (i) remove the object store and recreate it, or (ii) open a cursor and call remove for all entries. I propose a third, simpler approach: interface IDBObjectStore { ... void clear(); ... }; Any thoughts? Some background. At least in our implementation, removing each individual item is significantly slower than removing and recreating the objectStore. It's also significantly slower than a 'clear' function is. And while tearing down and recreating the objectStore works, it's fairly complex if there are multiple indexes on the store. Adding a clear() function, while redundant, should make things easier for developers while adding very little work in the implementation. I think there is a bug in the above proposal though. clear() should return a IDBRequest. However the .result of the request should likely be null. / Jonas +1 on having clear(). We ran into the need also while playing with samples and such. I filed a bug[1] on this and updated the spec [2]. [1] http://www.w3.org/Bugs/Public/show_bug.cgi?id=11266 [2] http://dvcs.w3.org/hg/IndexedDB/rev/5de451aac387 / Jonas
Re: [IndexedDB] Need a method to clear an object store
On Tue, Aug 3, 2010 at 11:02 PM, ben turner bent.mozi...@gmail.com wrote: On Tue, Aug 3, 2010 at 12:20 PM, Jonas Sicking jo...@sicking.cc wrote: I think there is a bug in the above proposal though. clear() should return a IDBRequest. However the .result of the request should likely be null. Yes, definitely. My fingers were too fast for my brain. I think adding a clear seems reasonable and shouldn't be that much overhead or surface area. J
RE: [IndexedDB] Need a method to clear an object store
From: public-webapps-requ...@w3.org [mailto:public-webapps-requ...@w3.org] On Behalf Of Jonas Sicking Sent: Tuesday, August 03, 2010 12:21 PM On Tue, Aug 3, 2010 at 12:09 PM, ben turner bent.mozi...@gmail.com wrote: Hi folks, Currently there are only two ways to clear an object store of all data: (i) remove the object store and recreate it, or (ii) open a cursor and call remove for all entries. I propose a third, simpler approach: interface IDBObjectStore { ... void clear(); ... }; Any thoughts? Some background. At least in our implementation, removing each individual item is significantly slower than removing and recreating the objectStore. It's also significantly slower than a 'clear' function is. And while tearing down and recreating the objectStore works, it's fairly complex if there are multiple indexes on the store. Adding a clear() function, while redundant, should make things easier for developers while adding very little work in the implementation. I think there is a bug in the above proposal though. clear() should return a IDBRequest. However the .result of the request should likely be null. / Jonas +1 on having clear(). We ran into the need also while playing with samples and such. -pablo
[IndexedDB] Need a method to clear an object store
Hi folks, Currently there are only two ways to clear an object store of all data: (i) remove the object store and recreate it, or (ii) open a cursor and call remove for all entries. I propose a third, simpler approach: interface IDBObjectStore { ... void clear(); ... }; Any thoughts? -Ben
Re: [IndexedDB] Need a method to clear an object store
On Tue, Aug 3, 2010 at 12:09 PM, ben turner bent.mozi...@gmail.com wrote: Hi folks, Currently there are only two ways to clear an object store of all data: (i) remove the object store and recreate it, or (ii) open a cursor and call remove for all entries. I propose a third, simpler approach: interface IDBObjectStore { ... void clear(); ... }; Any thoughts? Some background. At least in our implementation, removing each individual item is significantly slower than removing and recreating the objectStore. It's also significantly slower than a 'clear' function is. And while tearing down and recreating the objectStore works, it's fairly complex if there are multiple indexes on the store. Adding a clear() function, while redundant, should make things easier for developers while adding very little work in the implementation. I think there is a bug in the above proposal though. clear() should return a IDBRequest. However the .result of the request should likely be null. / Jonas
Re: [IndexedDB] Need a method to clear an object store
On Tue, Aug 3, 2010 at 12:20 PM, Jonas Sicking jo...@sicking.cc wrote: I think there is a bug in the above proposal though. clear() should return a IDBRequest. However the .result of the request should likely be null. Yes, definitely. My fingers were too fast for my brain. -Ben