Persisting data with LevelDB
LevelDB is an embedded database. It is a key-value store written by Google, where the data is sorted by key. LevelDB is commonly used in cases where fast access to large datasets is required. LevelDB is used directly as a library, so there is no server or command-line interface.
In this recipe, we're going to implement a task list using LevelDB as our store.
Getting ready
- To get started, create a directory named
leveldb-appcontaining a file namedtasks.js:$ mkdir leveldb-app $ cd leveldb-app $ touch tasks.js
- LevelDB is a library that we will install from the
npmregistry, so we'll need to initialize our project:$ npm init --yes
Now that we've initialized our project, we can move on to the recipe.
How to do it…
In this recipe, we'll be using the levelup and leveldown modules to create and interact with our LevelDB store:
- The first step is to install the
levelupandleveldownmodules from...