dburles:counter-cache

v0.2.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.

meteor-counter-cache

Cache the counts of an associated collection.

Usage

All definitions should be made server side only.

Examples

1// Sets up a 'booksCount' field on each author
2Authors.maintainCountOf(Books, 'authorId');
3
4// TODO: more examples

API

collection1.maintainCountOf(collection2, lookup, [name])

  1. collection1

The collection to store the counter on

  1. Arguments

collection2 — Meteor Collection
The collection to maintain a count of

lookup — String or Function
The field name on collection2 to perform the match against collection1 _id
or a callback function returning a value to match against collection1 _id

name — String
Optional. Specify a custom counter field name

License

MIT. (c) Percolate Studio

counter-cache was developed as part of the Verso project.