Commit 0436f3083376a08bde3bd294a19ad258ca7bc826

Authored by Ryan Glover
1 parent 58f2ec8896
Exists in master

Add example publication for Example collection to /server/publications.

Add example subscription for examplePublication to /client/routes/routes-authenticated.js.
... ... @@ -50,6 +50,7 @@ minimongo@1.0.6
50 50 mobile-status-bar@1.0.2
51 51 mongo@1.0.11
52 52 npm-bcrypt@0.7.7
  53 +npm-container@1.0.0
53 54 observe-sequence@1.0.4
54 55 ordered-dict@1.0.2
55 56 particle4dev:sass@0.3.0
... ...
client/routes/routes-authenticated.js
... ... @@ -6,6 +6,15 @@
6 6 Router.route('index', {
7 7 path: '/',
8 8 template: 'index',
  9 + subscriptions: function(){
  10 + return Meteor.subscribe('examplePublication');
  11 + /*
  12 + return [
  13 + Meteor.subscribe('examplePublication'),
  14 + Meteor.subscribe('examplePublication2')
  15 + ];
  16 + */
  17 + },
9 18 onBeforeAction: function(){
10 19 // Code to run before route goes here.
11 20 this.next();
... ...
server/publications/example.js
... ... @@ -0,0 +1,17 @@
  1 +/*
  2 +* Publications: Example
  3 +* Data publications for the Example collection.
  4 +*/
  5 +
  6 +Meteor.publish('examplePublication', function(){
  7 + // If need be, Meteor gives us access to the current user via this.userId.
  8 + // Example below shows using this.userId to locate documents where the
  9 + // owner field is equal to a userId. Additionally, a fields projection is
  10 + // added to specify which fields you want to return (where 1 = true and
  11 + // 0 = false).
  12 +
  13 + var user = this.userId;
  14 + var data = Example.find({"owner": user}, {fields: {"owner": 1}});
  15 +
  16 + return data;
  17 +});
... ...