【发布时间】:2017-03-08 02:15:07
【问题描述】:
我正在尝试在meteor-mongo 中使用findOne 处理错误。
从this stackoverflow question 看来,我应该能够通过执行collection.findOne({query}, function(err, result){ <handleError> } 来处理错误,但这样做会导致错误消息:
“匹配错误:Match.OneOf、Match.Maybe 或 Match.Optional 验证失败”
以下代码有效:
export default createContainer((props) => {
let theID = props.params.theID;
Meteor.subscribe('thePubSub');
return {
x: theData.findOne({_id: theID}),
};
}, App);
以下代码没有:
export default createContainer((props) => {
let theID = props.params.theID;
Meteor.subscribe('thePubSub');
return {
x: theData.findOne({_id: theID}, function(err,result){
if(!result){
return {}
};
}),
};
}, App);
我做错了什么,我应该如何解决这个错误?这是特定于流星的错误吗?
非常感谢任何帮助!
【问题讨论】:
-
那个匹配错误看起来像是由服务器上的匹配包生成的。您在浏览器控制台或服务器控制台中看到该错误吗?
-
嗨@zim,谢谢你的回复。这个错误是在浏览器控制台产生的