Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

LazyBoy

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

LazyBoy

A object document mapper for couchdb

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47
increased by4.44%
Maintainers
1
Weekly downloads
 
Created
Source

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?

Fixes

  • Tests for embedded docs and no value supplied
  • Revision tests on save
  • Query mixin not call create but own afterLoad Function

Plenty:

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

FAQs

Package last updated on 03 Aug 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc