我想在我的用户上创建一个架构。这是我的目录结构。
Users
-- collections.js
-- helpers.js
Players
-- collections.js
-- forms.js
但是,当我尝试在Players/collections.js
中添加来自Users/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 is not defined
。
有没有办法在meteor的其他文件中明确包含某些实体?
答案 0 :(得分:2)
创建全局项目。
在/lib/config/_namespace.js
添加以下行:G = {}
;
这将是您唯一没有"use strict"
。
现在将模式保存到全局对象:
G.PlayerSchema = new SimpleSchema(...
现在引用它:type: G.PlayerSchema
对于诸如集合,模式,实用程序函数,常量和反应词典之类的东西,这是一个很好的方法,无需打包所有东西。