Level / classic-level

An abstract-level database backed by LevelDB.
MIT License
58 stars 11 forks source link

what are the different between them #53

Closed AdaJass closed 1 year ago

AdaJass commented 1 year ago

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.

vweevers commented 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:

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:

vweevers commented 1 year ago

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:

And more features are coming soon:

AdaJass commented 1 year ago
  • 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?

vweevers commented 1 year ago

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.