Commit 0436f3083376a08bde3bd294a19ad258ca7bc826
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.
Showing
3 changed files
with
27 additions
and
0 deletions
Show diff stats
.meteor/versions
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 | +}); | ... | ... |