jkuester:meteor-publication-factory

v0.1.5Published 6 years ago

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

Meteor Publication Factory

Helps you to create standardized publications for common use cases.

Usage

1const Toys = new Mongo.Collection("toys");
2
3const allToys = PublicationFactory.createPublication({
4		collection: Toys, // the collection to be published
5		fields: { // the public fields
6			title: 1,
7			brand: 1,
8			price: 1,
9		},
10		filter: { // a predefined filter
11			brand: "Company A",
12		},
13		preventEmptyQueries: true, // throws err if publication is queries with {}
14		querySchema: { // throws if query is not mathcing the schema
15			_id:String,
16		},
17		roles: { // throws if user subscribes but is not in roles
18			names: [ "read-toys" ],
19			domain: "toystore",
20		},
21		limit: 20, // a default limit
22		sleep: 2500, // a default sleep if limit is exceeded
23		logger: function(...args) { // pass a custom function to log 
24			// whatever you want to do here
25		},
26});
27
28
29Meteor.publish("allToys", allToys);