I am using a meteorite and I have a question about the publish function (server side)
Meteor.publish('users', function () { .... }
I send documents to a browser that have the identifier of other collections. For example, a Task document belongs to a project.
{
title: '....',
projectId: 'KjbJHvJCHTCJGVY234',
...
}
I want to add a property to this document projectTitle, so I do not need to search for a project on the client. However, when I add this property to a function publish, it is not sent to the client. This is what I tried:
Meteor.publish('tasks', function () {
var tasks = Tasks.find();
tasks.forEach(function (task) {
var project = Projects.findOne({_id: task.projectId});
task.projectTitle = project.title;
});
return tasks;
}
Any suggestions for changing documents (not persistent) inside the publish function?
source
share