mongodb - Upserting on embedded document -


i have following document strucutre

{     "_id" : "nmbyyasdsa",     "objectid" : "asdsd"     "text" : "test",     ....     "publishedat" : isodate("2015-05-28t15:31:51z"),     "updatedat" : isodate("2015-05-28t15:31:51z"),     "data" : {         .....         "likecount" : 0,         "replycount" : 0     } } 

that use synchronise database external api. this, poll api once every minute , bulk upsert, matching on object id keep database date.

problem data subdocument doesn't updated when upserting, ideas why?

my bulkwrite method

mongo.collection.prototype.upsertbulk = function(matcher, documents, options) {   if (_.isempty(documents)) { throw error('empty list of documents provided'); }   options = options || {};    var operations = documents.map(function(_document) {     _document._id = random.id();      var operation = {       updateone: {         filter: {},         update: { $set: _document },         upsert: true       },     };     operation['updateone']['filter'][matcher] = _document[matcher];      return operation;   });    this.__mongocollection(function(collection) {     collection.bulkwrite(operations, options, function(error, result) {       if (error) { throw error; }       return result;     });   }); }; 


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -