Javascript 如何在Meteor中明确包含实体?

Javascript 如何在Meteor中明确包含实体?,javascript,node.js,meteor,Javascript,Node.js,Meteor,我想在我的用户上创建一个架构。这是我的目录结构 Users -- collections.js -- helpers.js Players -- collections.js -- forms.js 但是,当我试图在Users/collections.js中包含Players/collections.js中的内容时,它表示它没有定义 Meteor.users.attachSchema(new SimpleSchema({ // irrelevent stuff up here "pro

我想在我的用户上创建一个架构。这是我的目录结构

Users
-- collections.js
-- helpers.js
Players
-- collections.js
-- forms.js
但是,当我试图在
Users/collections.js
中包含
Players/collections.js
中的内容时,它表示它没有定义

Meteor.users.attachSchema(new SimpleSchema({
  // irrelevent stuff up here
  "profiles.player": {
    type: PlayerSchema,  // playerschema is defined in Players/collections.js
    optional: true
  }
}));
我始终得到错误代码
ReferenceError:PlayerSchema未定义

有没有办法在meteor的其他文件中显式包含某些实体

  • 创建一个全局项目。 在
    /lib/config/_namespace.js中添加一行:
    G={}
    ; 这将是您唯一一个不使用strict的文件

  • 现在将模式保存到全局对象:
    G.PlayerSchema=新的SimpleSchema(…

  • 现在参考它:
    type:G.PlayerSchema


  • 对于集合、模式、实用程序函数、常量和反应式词典等,这是一种很好的方法,不必打包所有内容。

    使用打包方法?是否必须使用打包方法,或者是否有其他方法?