【发布时间】:2015-01-12 22:02:47
【问题描述】:
我一直在关注the docs 如何使用 Node.js、mongoose、express 更新行程,以及几个堆栈溢出问题 here 和 here。
在我的控制器内部,我最初有一个保存,它正在工作,但我需要将它切换到更新。当我运行代码时,没有任何中断,place 如我所料正确记录到控制台,这进一步表明代码正在运行,但由于某种原因,它没有覆盖具有相同 placeIdentifier 的项目.
我做错了什么阻止更新?
我的控制器:
var place = {
identifier: placeIdentifier,
name: placeName,
location: Location,
travelStart: startDate,
travelEnd: endDate,
}
Place.findOneAndUpdate(
{identifier:placeIdentifier},
{ $set: place },
{upsert: true},
function() {
console.log(place)
console.log("place saved...")
}
);
【问题讨论】:
标签: node.js mongodb express mongoose