treojs / treo

Consistent API to IndexedDB
http://treojs.com
MIT License
258 stars 18 forks source link

Batch operations do not support integer keys #39

Open randalpinto opened 8 years ago

randalpinto commented 8 years ago

Hey Aleksey, nice little library, simple and straight-forward, keep it like that.

I have a change request that hopefully should be useful for other people: The "batch" operation in the object store does not support integer keys even though you can do a "put" of an integer key.

Can the batch operation interface be extended to support them?

alekseykulikov commented 8 years ago

Hey Randal, thank you! I've been also thinking about this. And maybe treo should have leveldb kind of batch API:

books.batch([
   { type: 'put', key: 1, value: { title: 'Book 1', author: 'Author 1' }, },
   { type: 'put', key: 2, value: { title: 'Book 2', author: 'Author 2' }, },
   { type: 'put', key: 3, value: { title: 'Book 3', author: 'Author 3' }, },
   { type: 'del', key: 4, },
])

It's more explicit, but not that nice :) Do you have another ideas?

randalpinto commented 8 years ago

Agree, the interface is not as succinct but I don't think there are many other options that would support put and del at the same time given their syntaxes.