treojs/treo

Batch operations do not support integer keys

Opened this issue · 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?

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?

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.