autolevel
v2.0.3
Published
automatically connect levelup using database url
Downloads
58
Maintainers
Readme
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
type | schemes/protocols | driver | Dependencies --------- | ------------------------ | ---------------------- | ------------------------------------------ plain | dir, level, leveldb | leveldown | levelup, leveldown mongodb | mongo, mongodb | mongodown | levelup, mongodown in-memory | ram, mem, memory | memdown | levelup, memdown mssql | mssql | sqldown | levelup, sqldown, mssql mysql | mysql | sqldown | levelup, sqldown, mysql mysql2 | mysql2 | sqldown | levelup, sqldown, mysql2 sqlite3 | sqlite, sqlite3 | sqldown | levelup, sqldown, sqlite3 postgres | pg, postgres, postgresql | sqldown | levelup, sqldown, pg, pg-query-stream
TODO
- multilevel + auth + manifest support