Tag: mongoose mean.io

在使用mongoosefindOneandUpdate时,不能读取未定义的属性“_id”

我正在使用mean.io来制作体育事件pipe理系统。我正在尝试使用rest api更新模型播放器,并从mongoose引发此错误: { _id: 5411c79895d600440c698fa1, email: 'dipesh.acharya@apexcollege.edu.np', name: 'Dipesh Acharya', username: 'dipesh.acharya', games: [ 5411bd54786cfe2420f1e27a ], teams: [], roles: [ 'authenticated' ] } [TypeError: Cannot read property '_id' of undefined] PUT /api/players/5411c79895d600440c698fa1 500 199.402 ms – 36 我也试图从播放器中删除_id保护,但它也不起作用。 我用来更新模型播放器的方法是: exports.update = function(req, res) { var player = req.player; player = _.extend(player, req.body); console.log(player); Player.findOneAndUpdate(req.params.playerId, player,{new:true}, […]