0
该项目被删除/从数据库中删除,但捕获错误是内部服务器错误。流星:collection.remove。(id)有效,但仍然捕获500错误
事件触发:
Template.post.events({
'click .delete': function() {
Meteor.call("deleteJob", this._id, function (err, result) {
if (!err) {
console.log("meteor call to remove job was good");
Bert.alert("Poof! Job deleted from the site.", "success");
Router.go('/');
} else {
Bert.alert("Rrrrr. No worky. " + err.reason + " " + result, "danger");
console.log("meteor call was bad", err);
}
});
}
});
方法调用:
Meteor.methods({
deleteJob: function (id) {
var post = Posts.findOne(id);
if (post.author !== Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
try {
var postId = Posts.remove(id);
return postId;
} catch (exception) {
// If an error occurs, return it to the client.
return exception;
}
}
});
删除()在尝试永远不应该返回,如果有一个陷阱,对不对?