我有
var Schemas = {};
Meteor.isClient && Template.registerHelper("Schemas", Schemas);
Schemas.Person = new SimpleSchema({
fullName: {
type: String,
index: 1,
optional: true,
},
email: {
type: String,
optional: true
},
address: {
type: String,
optional: true
},
isActive: {
type: Boolean,
},
age: {
type: Number,
optional: true
}
});
Run Code Online (Sandbox Code Playgroud)
在一个文件和
var Collections = {};
Meteor.isClient && Template.registerHelper("Collections", Collections);
Persons = Collections.Persons = new Mongo.Collection("Persons");
Persons.attachSchema(Schemas.Person);
Run Code Online (Sandbox Code Playgroud)
在另一个文件中.
我收到了错误ReferenceError: Schemas is not defined.很明显,我必须Schemas在我的collections.js文件中定义而不是将它们分开.但Meteor如何在单独的文件中使用代码?我可以访问一些对象和变量,而其他对象和变量是无法访问的.
我为用户设置了会话变量,用于跟踪和服务器的小更改,当用户注销并且新用户登录而不关闭浏览器时,会话变量仍处于活动状态.
示例Session.set("变量",变量)Session.get("variable")
我想我正在寻找的是如何在用户注销时强制页面重新加载.