【发布时间】:2013-06-02 19:02:41
【问题描述】:
我的 Posts.update() 似乎有问题;方法。
var postProperties = {
url: $(e.target).find('[name=url]').val(),
title: $(e.target).find('[name=title]').val()
}
Posts.update(currentPostId, {$set: postProperties}, function(error){
if (error) {
// display the error to the user
alert(error.reason);
}
else {
Meteor.Router.to('postPage', currentPostId);
}
});
currentPostId 可能没有错,因为 remove 工作正常:
Posts.remove(currentPostId);
所以 postProperties 对象必须是:
Object {url: "https://github.com/DiscoverMeteor/Microscope", title: "Random Title"}
帖子有一个网址、一个标题和一条消息。我有一个消息的 .deny() 方法,所以我不会更新它。
任何关于我做错了什么的见解?
感谢您的宝贵时间。
【问题讨论】:
-
currentPostId和this.currentPostId的值是多少? -
this.currentPostId 为“未定义”,在本例中 currentPostId 为“wHtYDGjRgbWMYnzMy”。所以我不明白为什么 currentPostId 失败而 this.currentPostId 没有。
-
this.currentPostId不会失败,因为没有要更新的记录。尝试使用Posts.update({_id: currentPostId}, ....) -
我仍然收到“内部服务器错误”。另外,_id = currentPostId 的帖子肯定存在。
标签: javascript meteor meteorite