I create a small API, I do some data validation on the client side of my application, and while I do this, I structure my data according to my mongoose scheme.
I'm trying to do it ...
router.route('/car') .post(function(req, res) { var car = new Car(); car = req.body;
but, of course, all car model parameters provided by mongoose are currently being deleted, so the save etc method no longer works.
I tried car.data = req.body , but this requires all my mongoose schemes to be wrapped in a data object, which is not so elegant.
I was wondering if there is a way to avoid preparing a car object that would be saved without long arms,
car.name = req.body.name; car.seats = req.body.seats; car.engine_size = req.body.engine_size;
etc
I essentially wish to make the equivalent of car.push(req.body); , but again .push() not available for mongoose models.
zupcfevf
source share