我想在流星蒙戈中使用findOne
來處理錯誤。Meteor-Mongo:錯誤處理findone
從this stackoverflow question,看來我應該可以做collection.findOne({query}, function(err, result){ <handleError> }
,但在一個errormessage的這樣做的結果來處理錯誤:
"Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation"
下面的代碼工作:
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);
我是什麼doi恩錯了,我該如何解決這個錯誤?這是一個流星特定的錯誤?
任何幫助,非常感謝!
匹配錯誤看起來像由服務器上的匹配包生成的東西。您在瀏覽器控制檯或服務器控制檯中看到該錯誤? – zim
嗨@zim,謝謝你的回覆。此錯誤在瀏覽器控制檯上生成 –