【发布时间】:2015-06-20 02:55:24
【问题描述】:
因此,我希望我的 Meteor 应用程序的 Categories 集合的内容始终可用于整个应用程序。我在某处读到,您可以通过将null 指定为Meteor.publish 函数的第一个参数(而不是名称)来做到这一点。
我使用了以下代码:
// Categories
Meteor.publish(null, function() {
return Categories.find();
});
当我启动我的应用程序时,我在应用程序启动时收到以下错误(上面的代码段位于<app>/server/publications/global.js):
Exception from sub id undefined ReferenceError: Categories is not defined
at [object Object].Meteor.publish.Meteor.users.find.fields.username [as _handler] (app/server/publications/global.js:8:12)
at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)
at [object Object]._.extend._runHandler (packages/ddp/livedata_server.js:950:1)
at [object Object]._.extend._startSubscription (packages/ddp/livedata_server.js:769:1)
at packages/ddp/livedata_server.js:1437:1
奇怪的是,它这么说,但该出版物似乎运行良好。 Mongol 报告说,Categories 数据在我的整个应用程序中都可用,并且没有其他地方发布该数据,所以它一定来自这个调用。
有什么想法吗?我有点困惑。我应该在返回之前检查子目录中是否存在类别吗?
【问题讨论】:
-
您在哪里定义类别?
-
它可能重新运行并在重新运行时找到了类别。