Giter Site home page Giter Site logo

lazyboy's Introduction

LazyBoy Object Modeller

Oh my word... What have you done?

My experiments into what it takes to create a object mapper for Couchdb. This has been something I've been thinking about for a while and whether its a viable option.

Currently its purely fun research. I've been reading through mongoose and couch-ar as imspiration.

#How do I use this thing?

Below is a quick cheatsheet but the docs can be found http://garrensmith.com/LazyBoy

Defining a model

var Model = require('LazyBoy');

Model.define('User', {
  name: String
  surname: {type: String, default: "Rambo"}
})

Creating and saving a model

var user = Model.create('User', {name: "John", surname: "Rambo"});

user.save(function (err, saved_user) {
    // .. do some other stuff here
})

Finding a model

Finding by Id

var user_id = "123456";

var User = Model('User');
User.find(user_id, function (err, user) {
    // .. do something with the user
})

Find all

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
})

Find by criteria

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
})

Logging

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

#What needs doing?

  • Should we allow custom ID's?
  • Better Type casting
  • Validations

#Changelog 11 Nov 2011 - Added Validations using node-validator 13 Sep 2011 - Add Id to serialised model 11 Sep 2011 - Add Before And After Remove Callbacks (Donnie Hedin) 17 Aug 2011 - Add support for custom methods

#Contributors

  • Donnie Hedin (sofa420)
  • 8bitDesigner

lazyboy's People

Contributors

8bitdesigner avatar fadrizul avatar garrensmith avatar sofa420 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.