Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
server-side level adapter for modella
JavaScript
branch: master

This branch is 20 commits ahead, 10 commits behind modella:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
.coveralls
.gitignore
.jshintrc
.tern-project
.travis.yml
Makefile
history.md
package.json
readme.md

readme.md

level-modella

NPM version Build Status Dependency Status Coverage Status Code Climate

Level plugin for modella.

install

npm install [--save/--save-dev] level-modella

example

var model = require('modella');
var store = require('level-modella');
var level = require('level')('/tmp/level');
var sublevel = require('sublevel');
var uid = require('uid');

var users_store = sublevel(level, 'users');

var User = model('user');

User.attr('id');
User.attr('name');
User.attr('email');
User.attr('password');

User.use(store(users_store));

/**
 * Initialize
 */

var user = new User;

user.id(uid(6))
    .name('matt')
    .email('mattmuelle@gmail.com')
    .password('test');

user.save(function(err) {
  console.log(user.toJSON());
});

api

store(db)

Use the plugin.

model.save([options,] fn)

model.put([options,] fn)

Save a model.

model.del([options,] fn)

model.remove([options,] fn)

Remove a model.

Model.get(key, [options,] fn)

Get a model. The object passes to the callback is a Model instance.

Model.get.all([options])

Returns a stream that will emit a model instance on each data event. Accepted options are the same that levelup accepts.

Model.remove.all([options,] fn)

Removes all models.

Model.db

level instance

license

MIT

Something went wrong with that request. Please try again.