Mongodb return old collection

后端 未结 3 2032
甜味超标
甜味超标 2021-01-24 13:05
router.post(\'/orders/finish\', function(req, res, next) {
var order_id = req.body.order_id;
var user_id  = req.body.user_id;
var table_id = \'\';

var result = [];



m         


        
3条回答
  •  灰色年华
    2021-01-24 13:31

    When you make your .find() call, your collection isn't done updating yet.

    You can choose to call .find() in the callback of your .update() call, or you could also use promises or async/await depending on your version.

    Another solution would be to use findAndModify with the new option:

    Optional. When true, returns the modified document rather than the original. The findAndModify() method ignores the new option for remove operations. The default is false.

提交回复
热议问题