dispatch:collection-view

v1.0.1Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

dispatch:collection-view

Create collection views.

Usage

1  var foo = new Mongo.Collection('foo');
2
3  var fooView = new CollectionView({
4    collection: foo,
5    transform: function(doc) {
6      return {
7        birthday: doc.birthday,
8        age: calculateAge(doc.birthday),
9        address: address.findOne(doc.addressId)
10      };
11    }
12  });

fooView acts like a regular Mongo.Collection and will update by observing on foo.

This allows sorting by dynamically generated attributes.

Api

There are two functions added:

  • foo.stop(); - This will stop the view and clear the view
  • foo.start(); - This will start the view or throw an error if already started

Note: Using the start will default values but you can also change the values foo.start(selector, transform)