Embedded persistence with LevelDB
LevelDB is an embedded database at Google, and inspired by of Google's proprietary BigTable database. It's a log-structured key-value store purposed for fast read/write access of large datasets.
LevelDB has no command-line or server interface; it's intended for use directly as a library. One of the advantages of an embedded database is that we eliminate peer dependencies-we don't have to assume that a database is available at a certain host and port: we simply require a module and use the database directly.
In this recipe, we're going to implement a quotes application on top of LevelDB.
Getting ready
There's no external database to install-all we need to do is create a folder, with an index.js
, initialize it as a package, and install some dependencies:
$ mkdir level-app $ cd level-app $ touch index.js $ npm init -y $ npm install --save level xxhash end-of-stream-through2
How to do it...
Let's start by loading our dependencies:
const {hash} = require('xxhash...