【发布时间】:2013-07-10 07:20:45
【问题描述】:
我正在使用咖啡脚本。我在网上读到,当使用带有 Meteor 的咖啡脚本时,全局变量,例如集合, 应该使用@定义。我已经这样做了,但我仍然收到以下错误。相关文件中的代码出现在错误之后。我该如何解决这个错误?
谢谢。
错误 --------
ReferenceError: GameStatus is not defined
at app/server/methods/adminMethods.coffee.js:10:5
---------------------------------- 收藏/gamestatus.coffee ----------------------------------
@GameStatus = new Meteor.Collection('gamestatus')
---------------------------------- 服务器/adminMethods.coffee ----------------------------------
Meteor.methods
initializeGameStatus: () ->
GameStatus.insert({gameOnOff: 0, asymmetric: 0})
if GameStatus.find({}).count() is 0
Meteor.call 'initializeGameStatus', (err, result) ->
if err
console.log(err)
else
'GameStatus collection initialized'
【问题讨论】:
-
你为什么要定义新的 Meteor.Collection ?这是新的 Mongo.Collection
标签: javascript coffeescript meteor