I have a meteor app that have the following publish function (using coffeescript):
Meteor.publish "apps", ->
apps = Apps.find {},
fields :
name : 1
description : 1
icon : 1
fileIds = []
apps.forEach (doc, idx, cursor) ->
if (doc.icon)
fileIds.push(doc.icon)
console.log(fileIds)
files = Files.find {_id : { $in : fileIds}}
[apps, files]
Note I have a console.log in it to check when the publish function gets run. After I insert an element to collection Apps. I don't see the publish function re-run. The problem for me is that the Apps collection contains a field icon, which is the _id of an item in Files collection (using CollectionFS). when I insert an item to apps, a file is uploaded and an item is inserted to Files collection as well. However, because the publish function is not re-run, the newly created File item is not published to the client, so the client cannot see the file.
What is the problem here?
Thanks.