These are chat archives for Automattic/mongoose

9th
Feb 2018
Arun Gadag
@arun-awnics
Feb 09 2018 12:24
Hi everyone
I am trying to update a record in my database and return the updated record. But it return null value
exports.update = (message, callback) => {
    var condition = { $and: [{ 'senderId': message.senderId }, { 'receiverId': message.receiverId }, { 'createdTime': message.createdTime }] };
    var options = { "new": true }; //multi: true, upsert: true

    Message.findOneAndUpdate(condition, {
        $set: {
            "text": message.text,
            "type": "text",
            "contentType": "text"
        }
    }, options, (message) => {
        callback(message);
        console.log('updated message dao ', JSON.stringify(message));
    });
}
I get message:null
Kev
@lineus
Feb 09 2018 16:41
try adding an error to your call back (err, message) =>
@arun-awnics ^