0
我试图更新我的模型的值,但它不起作用。 奇怪的是我正在打印结果,它看起来与我在数据库中使用Robomongo所看到的不同。 任何想法为什么会发生这种情况?DB,node.js和mongoose中的值未更新
这里是我的代码:
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
});
}
};
当我检查数据库的状态仍然未决。
谢谢,成功了! – user3464679