我现在正在制作测验应用程序,我的correct变量似乎从未更新过。我正在调用function correctTest(),如果我单击包含用于测验正确答案的单选功能,则会正确调用该。但是,我坚持使用正确的语法进行更新。

$http.put('/quizQuestions', {
  isRight: $scope.quizQuestions[$index][isRight]+1
});


我发布使用:

  router.put('/quizQuestions', function(req, res) {
    db.quizQuestions.update({
  isRight: req.body.isRight
}, {}, function(err, data) {
  res.json(data);
});


});

抱歉,我粘贴了错误的方法副本

最佳答案

应该:

db.quizQuestions.update({ <query to find the record to update>}, {$set:{isRight: req.body.isRight}}, function(err, data) { res.json(data);...

07-21 12:06