LazyBoy is a Couchdb Object Document Model. It has full support for relations, type casting, custom views and querying.
Ask questions on the #lazyboy IRC channel.
var Model = require('LazyBoy');
Model.define('User', {
name: String
surname: {type: String, default: "Rambo"}
})
var user = Model.create('User', {name: "John", surname: "Rambo"});
user.save(function (err, saved_user) {
// .. do some other stuff here
})
var user_id = "123456";
var User = Model('User');
User.find(user_id, function (err, user) {
// .. do something with the user
})
Will return an array of all documents that fit the criteria
var User = Model('User');
User.all(function (err, users) {
// .. do something with the user
})
Will return an array of all documents that fit the criteria
var User = Model('User');
User.where(name,"Ben", function (err, users) {
// .. do something with the user
})
To see in detail what is happening the logging can be turned on. This can be done by
require('LazyBoy').logger.setLogLevel(1);
LazyBoy uses Coloured logger under the covers and uses the same log levels