I am using https://github.com/VeliovGroup/Meteor-Files to upload the file.
I have “choices” collection which have each choice which containes a image each.
I have published the images file,
pub.js (server side)
Meteor.publish(‘files.images.all’, function () {
return Images.find().cursor;
});
main.html
{{#each choices}}
{{> choice}}
{{/each}}
{{name}}
main.js
Template.main.onCreated(function{
this.subscribe(‘Choices’);
});
Template.choice.onCreated(function(){
this.subscribe(‘files.images.all’);
});
Template.choice.helpers({
getImage(id) {
return Images.findOne({_id:id}).link();
}
});
I get Exception in template helper: getImage.
What I want is I have to display all the choices with their image & names.
I have the choices collections with data schema like
{name:“some choice”, featured_image:{ _id:“KcLkabv2wPiSwLpm6” }}
I am trying to get the link of the image by passing the ID to image collection.
How can I achieve this?
Is my approach is wrong?
I am new to meteor.