UNPKG

modella-collector

Version:

Modella plugin to enable collection attributes

29 lines (22 loc) 662 B
# modella-collector [modella](http://github.com/modella/modella) plugin to enable collection attributes. ## Usage ```js 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" ```