modella-collector

Modella plugin to enable collection attributes

Usage no npm install needed!

<script type="module">
  import modellaCollector from 'https://cdn.skypack.dev/modella-collector';
</script>

README

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"