Home

Awesome

autolevel

Automatically use the right abstract-leveldown module for your configuration

Installation

npm install --save autolevel

For a full installation, supporting all types included in the code, run the following:

npm install --save autolevel levelup leveldown mongodown memdown sqldown mssql mysql mysql2 sqlite3 pg pg-query-stream

Why

I was tired of looking for which combination of modules to install every time I started a new project for myself or work using leveldb. This is simply a documented wrapper for common abstract-leveldown adapters, passing options to the used abstract-leveldown module and returning a levelup instance.

Below you'll find which extra dependencies you'd need to connect to certain backends.

Examples

// Load autolevel
const autolevel = require('autolevel');

// Some variables we'll show
var db;

// Autodetect backend using environment variables
db = autolevel();

// Load database from folder, relative to the app root
db = autolevel('dir:data/');

// Load database from folder, absolute path
db = autolevel('dir://data/');

// Use mongodb storage
db = autolevel('mongodb://localhost:27017/database');

// Use authenticated mysql backend
db = autolevel('mysql://username:password@host:3306/database');

Adapters

typeschemes/protocolsdriverDependencies
plaindir, level, leveldbleveldownlevelup, leveldown
mongodbmongo, mongodbmongodownlevelup, mongodown
in-memoryram, mem, memorymemdownlevelup, memdown
mssqlmssqlsqldownlevelup, sqldown, mssql
mysqlmysqlsqldownlevelup, sqldown, mysql
mysql2mysql2sqldownlevelup, sqldown, mysql2
sqlite3sqlite, sqlite3sqldownlevelup, sqldown, sqlite3
postgrespg, postgres, postgresqlsqldownlevelup, sqldown, pg, pg-query-stream

TODO