treo icon indicating copy to clipboard operation
treo copied to clipboard

Batch operations do not support integer keys

Open randalpinto opened this issue 9 years ago • 2 comments

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?

randalpinto avatar Nov 19 '15 14:11 randalpinto

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?

alekseykulikov avatar Nov 19 '15 16:11 alekseykulikov

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.

randalpinto avatar Nov 19 '15 18:11 randalpinto