【发布时间】:2015-12-09 08:05:04
【问题描述】:
在HAPI和mongoskin中创建了一个服务器,问题是服务器没有更新集合中的文档。
我尝试了很多方法,我正在关注别名文档 hapi 和 mongoskin,但仍然没有成功。
服务器放置:
{
method: 'PUT',
path: '/{collectionName}/{id}',
handler: function(req, reply){
loadCollection(req.params.collectionName,
function(collection){
collection.updateById(
{_id: id(req.params.id)},
{$set: req.payload},
{safe: true, multi:false},
function(e, result){
if (e) return reply(e)
reply((result === 1) ? {msg: 'success', result: result} : {msg: 'error', result: result})
}
)
}
)
}
}
角度控制器:
$scope.item.put().then(function(res){
//$scope.item._etag.$oid = res._etag;
//$scope.loadItem();
toast.msgToast($scope.section+ ' #' +$scope.item._id+ ' ....Atualizado!');
});
【问题讨论】:
标签: angularjs mongodb hapijs mongoskin