在嵌入式文档上插件

时间:2015-05-29 14:15:52

标签: mongodb

我有以下文件结构

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;
    });
  });
};

用于将我的数据库与外部API同步。为此,我每分钟调查一次API并执行批量upsert,匹配对象ID以使我的数据库保持最新。

问题是Energy = (1/N) * Sum(Abs(x[n])) //Where N is total number of samples in the x slice 子文档在upsert时没有更新,有关于为什么的任何想法?

我的bulkwrite方法

struct sockaddr_in6 ServerAddress;
ListenSocket = WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
...
ServerAddress.sin6_family = AF_INET6;
if (InetPton(AF_INET6, "::1", sockAddr.sin6_addr.s6_addr) != 1) printf("error, inet_pton() failed!\n");
ServerAddress.sin6_port = htons(nPortNo);

0 个答案:

没有答案