Skip to content

meteorblackbelt/meteor-collection-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tracking for collections

Add tracking to collections.

Install

meteor add meteorblackbelt:collection-tracker

Usage

Basic usage examples.

Attach

Posts = new Mongo.Collection('posts');

//Attach behaviour with the default options
Posts.attachBehaviour('trackable');
// or
CollectionBehaviours.attach(Posts, 'trackable');

//Attach behaviour with custom options
Posts.attachBehaviour('trackable', {
  fieldName: 'postChanges',
  include: ['name']
});
// or
CollectionBehaviours.attach(Posts, 'trackable', {
    include: ['name']
});

CollectionBehaviours.attach(Posts, 'trackable', {
    exclude: ['search']
});

Multiple trackers

More than one tracker can be defined on the same collection by passing an array of options as follows

Posts.attachBehaviour('trackable', [
  {
    include: ['name']
  },
  {
    fieldName: 'commentChanges',
    include: ['comments']
  }
]);

Options

The following options can be used:

  • include: array of fields to include (default is all)

  • exclude: array of fields to exclude (default is none)

  • fieldName: name of field that changes are tracked under (default is 'changes')

Global options

CollectionBehaviours.configure('trackable', {
  include: ['createdAt']
});

About

Extends Mongo.Collection with tracking of changes to documents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published