Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 101 lines (63 sloc) 1.524 kb

lilmodel

A li'l backbone-ish model object.

Browser usage

load dist/lilobj.js or dist/lilobj.min.js in you browser and call it like this:

(function () {

  var model = require('lilmodel').model;

  var beer = model.extend({

    defaults: {
      sizeInLiters: 0.5,
    },

    rules: {
      type: ['required', 'string']
      sizeInLiters: ['required', 'number', ['gte', 0.2]]
    }

  });

  var dunkel = beer.create({
    type: 'lager',
  });

  dunkel.save(function (err) {
    //callback from sync 
  });

}());

Node usage

install the module with: npm install lilmodel

var beer = model.extend({

  defaults: {
    sizeInLiters: 0.5,
  },

  rules: {
    type: ['required', 'string']
    sizeInLiters: ['required', 'number', ['gte', 0.2]]
  }

});

var dunkel = beer.create({
  type: 'lager',
});

dunkel.save(function (err) {
  //callback from sync 
});

Documentation

syncr(syncMethod)

model.extend(config)

model.create(properties)

model.validate()

model.save(callback, context)

model.fetch(callback, context)

model.destroy(callback, context)

model.serialize()

collection.extend(config)

collection.create(propertiesList)

collection.validate()

collection.add(properties)

collection.remove(query)

collection.get(query)

collection.find(query, callback, context)

collection.serialize()

License

Copyright (c) 2012 August Hovland Licensed under the MIT license.

Something went wrong with that request. Please try again.