Mongoose validation error but I put documents correctly

后端 未结 2 959
说谎
说谎 2021-01-28 00:11

Please take a look at my code. I am having a validation error but I am quite sure that I put my documents on the correct format.

MY MODEL



        
2条回答
  •  天命终不由人
    2021-01-28 01:10

    You seem to have asked the same question about the array in a separate post - you should avoid duplicating your questions.

    The answer is shorter -> you have no need of processing your req.body as it matches the required schema of your model. This should work fine:

    ordersRouter.route('/placeOrder')
        .post(function (req, res) {
    
            Orders.create(req.body, function (err, result) {
                if (err) throw err;
    
                // send success message back
            });
        });
    

提交回复
热议问题