LevelDB
Installation
npm install modella-leveldb
Example
var model = ;var level = './mydb';var uid = ; var User = ; User; /** * Initialize */ var user = ; userid name'matt' ; user;
API
Level(path|db, options)
Initialize leveldb with a path
to the database. If path doesn't exist, it will be created. options
will be passed through to levelup
Alternatively, you can pass your own level db
instance in.
Model.index(index, opts)
Create a secondary index
using leveldex. You may ensure that key is unique by passing unique : true
in opts
.
Userindex'email' unique: true ;
Model.all([options], fn)
Get all models (static method)
Model.find(id|object, [options], fn)
Find a model (static method).
If you provide a secondary index, you can search by that key:
Model;
model.save([options], fn)
Save the model (instance method)
model.remove([options], fn)
Remove the model (instance method)
All options
will be passed through to levelup.
License
MIT