我正在尝试创建2个集合之间的关系,但其中一个集合不可用于其他引用。具体来说,我有2个集合:Sites和ContentTypes。这是他们包括:由于缺少集合对象导致Collection2关系错误
// app/lib/collections/sites.js
Sites = new Mongo.Collection('sites');
Sites.attachSchema(new SimpleSchema({
name: {
type: String,
label: "Name",
max: 100
},
client: {
type: String,
label: "Client",
max: 100
},
created: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date;
} else if (this.isUpsert) {
return {$setOnInsert: new Date};
} else {
this.unset(); // Prevent user from supplying their own value
}
}
}
}));
而这里的CONTENTTYPES集合:
// app/lib/collections/content_types.js
ContentTypes = new Mongo.Collection('content_types');
ContentTypes.attachSchema(new SimpleSchema({
name: {
type: String,
label: "Name",
max: 100
},
machineName: {
type: String,
label: "Machine Name",
max: 100
},
site:{
type: Sites
},
created: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date;
} else if (this.isUpsert) {
return {$setOnInsert: new Date};
} else {
this.unset(); // Prevent user from supplying their own value
}
}
}
}));
当我添加的网站参考CONTENTTYPES模式,我的应用程序崩溃与错误:
ReferenceError: Sites is not defined at lib/collections/content_types.js:32:11
我还没有找到很多运气,找到收藏2中超过this的关系的文档。它看起来像那里引用的格式应该基于this thread。