Mongoose Changing Schema Format

Considering your Mongoose model name as sweepstakesModel,
this code would add enabled field with boolean value false to all the pre-existing documents in your collection:

db.sweepstakesModel.find( { enabled : { $exists : false } } ).forEach(
    function (doc) {
        doc.enabled = false;
        db.sweepstakesModel.save(doc);
    }
)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)