我在lib中定義的採集服務器/ main.js創建的集合/ collection.js流星不能訪問
var Tags = new Meteor.Collection("Tags");
然後試圖在服務器/ main.js將其初始化:
Tags.insert({name: tag["tag"], default_show: true});
有錯誤: W20141028-01:26:53.647(11)? (STDERR)ReferenceError:標籤未定義 W20141028-01:26:53.648(11)? (STDERR)在應用程序/服務器/ main.js:43:18
我不明白爲什麼我在這裏得到錯誤?任何人都可以給我一些提示?
完整的源代碼:
服務器/ main.js
Meteor.startup(function() {
var tagsJson = JSON.parse(Assets.getText("tags.json"));
var tagsMapJson = JSON.parse(Assets.getText("tags_map.json"));
tagsJson["lines"].map(function(line) {
line["tags"].map(function(tag){
if (!Tags.findOne({name: tag["tag"]})) {
Tags.insert({name: tag["tag"], default_show: true});
}
tagsMapJson[tag["tag"]].map(function(web) {
if (!Webs.findOne({url: web["url"]})) {
Webs.insert({url: web["url"], name: web["name"], brief: web["brief"]});
}
if (!TagWebs.findOne({tag: tag["tag"], url: web["url"]})) {
TagWebs.insert({tag: tag["tag"], url: web["url"]});
}
});
});
});
});
的lib/collections.js
var Tags = new Meteor.Collection("Tags");
var Webs = new Meteor.Collection("Webs");
var TagWebs = new Meteor.Collection("TagWebs");
可能的重複[如何從Meteorjs中的多個文件訪問集合?](http://stackoverflow.com/questions/18354549/how-do-i-access-a-collection-from-one-file-in-meteorjs) – 2014-10-27 14:57:08