Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A li'l backbone-ish model object
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
dist
lib
test
.gitignore
.npmignore
LICENSE
README.md
grunt.js
package.json

README.md

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.