Level / level-browserify

No longer maintained: superseded by level v5.0.0.
MIT License
63 stars 16 forks source link

Cross-db compatibility guidelines? #19

Closed paulkernfeld closed 6 years ago

paulkernfeld commented 8 years ago

I would find it helpful to have some guidelines for making code portable to both level.js and leveldown. Basically, I tried to port some leveldown code into level-browserify, thinking that it would "just work," but it turned out that it didn't. Is that something that we could add into the README of this project?

As far as specifics, the only thing that I'm aware of is that level.js likes ArrayBuffers whereas leveldown likes Buffers. Are there other details worth mentioning?

juliangruber commented 8 years ago

Hmm, tbh I'm not aware of any other differences, the goal should be really to make them as similar as possible.

vweevers commented 7 years ago

Though this only starts to show with big datasets (in the thousands), IMO the biggest and most problematic difference is the lack of backpressure. You have to consume data as fast as it comes out, or accept memory spikes. IndexedDB cursors (and therefor level iterators and read streams) can't be paused, or in other words, they push, rather than being pulled from.

vweevers commented 6 years ago

As far as specifics, the only thing that I'm aware of is that level.js likes ArrayBuffers whereas leveldown likes Buffers.

The next release of level-browserify, with level-js@3, will also prefer Buffers. In addition, it will support binary keys, have snapshot guarantees and pass the full abstract-leveldown test suite. Please see the (work-in-progress) upgrade guide in https://github.com/Level/level-js/pull/143 for more details.