Closed AdaJass closed 1 year ago
The backstory of abstract-level
can be found in the FAQ: What is abstract-level
?
The short version, that I hope will answer your more specific questions, is this:
leveldown
was a Node.js binding for LevelDBlevelup
wrapped leveldown
in a more convenient interface, later indeed including promisesleveldown
and levelup
are now legacy modulesclassic-level
is effectively a merger of leveldown
and levelup
. It's thus a binding to LevelDB with a convenient interface. I say effectively because the real story is more nuanced and can be found in the FAQ that I mentioned.If I instead were to explain the relationships to someone that's new to Level (and thus doesn't have to know about leveldown
and levelup
), then I would say, using OOP terms:
AbstractLevel
is an abstract class for a lexicographically sorted key-value database. It handles state, encodings and other generic behaviors that can be implemented in pure JavaScript.ClassicLevel
implements that abstract class, using LevelDB for storage.In case your question is, should I use classic-level
or leveldown
? Then the answer is classic-level
, without a doubt.
Legacy modules like leveldown
are no longer maintained. They work perfectly fine, but won't get new features, performance improvements or other updates. Feature-wise, classic-level
has the following additional features:
iterator.nextv()
and iterator.all()
And more features are coming soon:
AbortSignal
AbstractLevel
is an abstract class for a lexicographically sorted key-value database. It handles state, encodings and other generic behaviors that can be implemented in pure JavaScript.ClassicLevel
implements that abstract class, using LevelDB for storage.
Thanks a lot, I saw the compare with levelDB and rocksDB in internet, it is said rocksDb is the better one. By your mention, I could write code with abstractlevel or classiclevel, but if i want in the future, i could just simply replace the require/import package, it is that right?
will you plan to upgrade the rocksdb package to the abstractlevel style?
We don't have a (new) RocksDB binding yet, see https://github.com/Level/abstract-level/issues/14. I can't say when that will happen, it's low priority atm.
But yes, once that's available, you could replace const { ClassicLevel } = require('classic-level')
with const { RocksLevel } = require('rocks-level')
and you'll get the same interface.
PS. "Better" is subjective. LevelDB is a good choice (and the most popular among Level users) when you want small binaries, a wide range of supported platforms, and good general performance (that isn't optimized for one particular scenario like SSDs). RocksDB does have more features, but the majority are not exposed in our bindings because those features don't fit in the abstract-level
interface and RocksDB receives less attention from us.
I'm trying to use levelDB in my program. You have done lots of brilliant jobs to introduce levelDB to nodejs. But I found the repository make me a little confuse. Maybe there should be a graph to make it straight to users which will explain the relationship between them. It just my little suggestion.
I am not sure but I guess their relationships should be like this: the abstract is the version completely written by asyn/await version of js, the leveldown is wrap with convenient interface upon the c++ binary leveldb, and the levelup introduce nodejs promise like feature to leveldown.