Reputation: 4376
main.html:
{{#each getRequests}}
<li><a href="/req/{{_id}}">{{_id}}</a></li>
{{/each}}
main.js
if (Meteor.isClient) {
Meteor.subscribe('getRequests',{fbID : Meteor.user().services.facebook.id});
}
publications.js
Meteor.publish('getRequests', function(args) {
return data.find({"potentialUsers.user_id" : args.fbID});
});
I'm stuck trying to get the main.html to display the IDs from the database. The user's ID can be in multiple documents in the "data" table, nested within data.potentialUsers.user_id. What I don't understand is that when I put the query into meteor mongo
(in the command line) it executes successfully.
Upvotes: 0
Views: 34
Reputation: 797
I am fairly new to meteor myself, but reading through the docs I see these issues.
Subscribe makes the documents available to the client from the publication. You still need to write a function to deliver them to the html.
main.js
if (Meteor.isClient) {
Meteor.subscribe('getRequests',{fbID : Meteor.user().services.facebook.id});
Template.body.helpers({
getRequests: function(){
return data.find() // since you want everything the publication has.
}
})
}
Then in your html:
{{#each getRequests}}
<li><a href="/req/{{_id}}">{{_id}}</a></li>
{{/each}}
Upvotes: 1