Showing posts with label Mongodb. Show all posts
Showing posts with label Mongodb. Show all posts

Friday, December 4, 2015

after update mongodb callback result in nodejs

after update mongodb

nodejs code

message_model.update(message_cond, { seen: true }, function (doc) {
            Object.getOwnPropertyNames(doc).forEach(function (prop, idx, array) {
                var val = doc[prop];
                console.log(prop + ":" + val);
            });
            console.log('===============');
            for (var prop in doc) {
                var val = doc[prop];
                console.log(prop + ":" + val);
            }
            console.log('===============');
            console.log(utils.tojstr_(doc.result));
            console.log('===============');
            console.log(utils.tojstr_(doc));
.............................
});

console.log

result:[object Object]
connection:56
matchedCount:2
modifiedCount:2
upsertedId:null
upsertedCount:0
===============
result:[object Object]
connection:56
matchedCount:2
modifiedCount:2
upsertedId:null
upsertedCount:0
toJSON:function () {
  return this.result;
}
toString:function () {
  return JSON.stringify(this.toJSON());
}
===============
{"ok":1,"nModified":2,"n":2}
===============
{"ok":1,"nModified":2,"n":2}

if insert query running
then doc.ops is inserted document