"Exception in template helper: ELEMENT_OPERATORS.$in.compileElementSelector@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1887:1
operatorBranchedMatcher/<@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1569:1
_.forEach@http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:164:13
operatorBranchedMatcher@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1549:3
compileValueSelector@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1453:12
compileDocumentSelector/<@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1432:9
_.forEach@http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:164:13
compileDocumentSelector@http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:1415:3
._compileSelector@http://localhost:3000/packa"[…] meteor.js:887帮助者:
return WorkClassification.find({_id : {$in: this.classifications }});但它会返回正确的数据。我在控制台中看到了上面的异常。但它是有效的。是什么导致了这种异常?
发布于 2015-04-14 05:54:57
我只是在我的meteor应用程序中遇到了同样的错误。将你的例子外推到我的例子中,这个问题的产生是因为this.classifications是未定义的,并且$in要求值是和数组。当分类数组从未用空数组初始化(绝对不是必需的)时,就会发生这种情况。
if (!this.classifications || !classifications.length) return [];
return WorkClassification.find({
_id : {
$in: this.classifications
}
});另一种解决方案是:
return WorkClassification.find({
_id : {
$in: this.classifications || []
}
});--
编辑:我只是意识到第一个解决方案在这些情况下不会是被动的(因为.find()不会被执行)。但是,我不确定,因为我没有测试过它。正因为如此,最好和更安全的解决方案将只是第二种选择。
发布于 2015-01-11 21:50:46
你不能对id进行匹配,你可以应用它来搜索你找到的记录中的某些字段,但不能搜索记录本身。
如果this.classifications持有id,则使用
return WorkClassification.find({_id : this.classifications});
https://stackoverflow.com/questions/27886336
复制相似问题