dougal

0.1.2 • Public • Published

Dougal

Build Status Coverage Status

The M of MVC, for Javascript VC frameworks that lack a decent M.

Getting Started

Install Dougal:

$ npm install aol/dougal
<script src="node_modules/dougal/dougal.js"></script>

Define models:

var Employee = Dougal.Model.extends(function () {
  this.baseUrl = '/employees';
 
  this.attribute('id');
  this.attribute('name');
 
  this.validates('name', {presence: true, message: 'Name is required'});
});

Create a new record:

var newHire = new Employee({name: 'John Doe'});

Validate the record:

newHire.isValid(); // true
newHire.name = '';
newHire.isValid(); // false
newHire.errors.name; // ['Name is required'];

Save the record:

newHire.save();
// POST /employees {name: 'John Doe'}

Angular.js integration

<script src="node_modules/dougal/dougal-angular.js"></script>
angular.module('your.app', ['dougal'])
  .factory('Employee', ['Dougal', function (Dougal) {
    function Employee() {
      // Model definition here
    }
    return Dougal.Model.extends(Employee);
  }])
  .controller('YourController', function (Employee) {
    this.employee = new Employee();
  });

Readme

Keywords

none

Package Sidebar

Install

npm i dougal

Weekly Downloads

0

Version

0.1.2

License

Apache-2.0

Last publish

Collaborators

  • manudwarf