0.0.5 • Published 10 years ago

modella-collector v0.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

modella-collector

modella plugin to enable collection attributes.

Usage

var modella = require('modella');
var collector = require('modella-collector');

var Disc = modella('Disc')œ
  .attr('artist', {type: 'string'})
  .attr('name', {type: 'string'});

var Fan = modella('Fan')
  .attr('name', {type: 'string'})
  .attr('discs', {type: [Disc]})
  .use(collector);

var jack = new Fan({
  name: 'Jack',
  discs: [
    {artist: 'The Beatles', name: 'Sgt. Pepper\'s Lonely Hearts Club Band'},
    {artist: 'The Who', name: 'My Generation'}
  ]
});

console.log(jack.discs().first().artist()); // "The Beatles"