DB、node.js和mongoose中未更新的值

DB、node.js和mongoose中未更新的值,node.js,mongoose,Node.js,Mongoose,我正在尝试更新模型的值,但它不起作用。 奇怪的是,我正在打印结果,它看起来与我使用Robomongo在数据库中看到的不同。 你知道为什么会这样吗 这是我的密码: exports.create = function(req, res) { var productId = req.query.product; if (productId) { Request.createWizard(req.user, { productId: productId }, function(err,

我正在尝试更新模型的值,但它不起作用。 奇怪的是,我正在打印结果,它看起来与我使用Robomongo在数据库中看到的不同。 你知道为什么会这样吗

这是我的密码:

exports.create = function(req, res) {
  var productId = req.query.product;

  if (productId) {
    Request.createWizard(req.user, { productId: productId }, function(err, request) {
      Product.findById(productId, function(err, product) {
        if (err) {
            return console.log('oh no! error', err);
        } else {
          if (product.price =! 0 ) 
            request.status = 'ready';
            console.log(request);
            (Here I see in the terminal: status = ready)
        }  
      });
      req.flash('success', { msg: 'Your request has been successfully created.' });
      res.redirect('/discover');
    });
  } else {
    var pages = require('../../schemas/wizard/request')();
    res.render('requests/form', {
      title: 'Make a Request',
      pages: pages,
      saveState: false
    });
  }
};

当我检查数据库状态时,它仍然处于挂起状态。

您正在更改status属性,但执行此操作后不会将文档保存回数据库:

Request.createWizard(req.user, { productId: productId }, function(err, request) {
  Product.findById(productId, function(err, product) {
    if (err) {
        return console.log('oh no! error', err);
    } else {
      if (product.price !== 0) {
        request.status = 'ready';
        request.save(function(err) { // <-- save it back to the database
          if (err) {
            console.log('oh no! error', err);
          } else {
            console.log(request);
          }
        });
      }
    }  
  });
  req.flash('success', { msg: 'Your request has been successfully created.' });
  res.redirect('/discover');
});
Request.createWizard(req.user,{productId:productId},函数(err,Request){
Product.findById(productId,function)(err,Product){
如果(错误){
返回console.log('oh no!error',err);
}否则{
如果(产品价格!==0){
request.status='ready';
请求保存(函数(错误){//