Wednesday, 7 June 2017

Mongoose Document not saving correctly

I've been bashing my head against this all day - I've got a doc that's just not saving to my db

router.post('/changeStatus', function(req, res, next) {
    console.log(req.body.id);
    console.log(req.body.status);

    Campaign.findById(req.body.id, function(err, tank) {
        // correctly pulls the document
        if (err) return handleError(err);
        // it's a string in the model
        tank.status = 'test';

        tank.save(function(err, updatedTank) {
            // correctly shows here
            console.log(updatedTank.status);
        });
   }); 

... 

// doesn't update the DB

Is there something obvious I'm missing here?

Thanks



via Ollie

No comments:

Post a Comment