These are chat archives for Automattic/mongoose

4th
Jan 2019
Hernando Hurtado Hoyos
@hernandoh
Jan 04 20:36

Hello anybody, i have a problem with save() funtion of mongoose model, in resume the data is not save, I would appreciate any help.
This is my model and code for save data

Model:

let logSchema = new Schema({
    status: { type: Boolean, required: [true, 'El estatus es requerido'] },
    descripcion: { type: String, required: [true, 'La descripción del log es necesaria'] },
    documento: { type: String, required: false },
    fecha: { type: Date, default: Date.now, required: [true, 'La fecha del log es necesaria'] }
});
module.exports = mongoose.model('Log', logSchema,'Log');

Code:

let registro = new Log({
        status: objlog.status,
        descripcion: objlog.descripcion,
        documento: documento,
        fecha
    });

    registro.save((err, logDB) => {
        if (err) {
            mensaje = 'Error al guardar el log de' + objlog.descripcion + ': ' + err;
            return mensaje;
        }
        return mensaje;
    });