Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js MongoDB-从节点执行存储的函数,无需评估_Node.js_Mongodb_Eval_Stored Functions - Fatal编程技术网

Node.js MongoDB-从节点执行存储的函数,无需评估

Node.js MongoDB-从节点执行存储的函数,无需评估,node.js,mongodb,eval,stored-functions,Node.js,Mongodb,Eval,Stored Functions,我在db.system.js中存储了一个函数: function(ticker) { var rtn = [], last = undefined; db[ticker].find({}).sort({_id: 1}).forEach((element) => { if(last != undefined) { if(element._id - last._id > 60*1000) { for

我在db.system.js中存储了一个函数:

function(ticker) {
    var rtn = [], last = undefined;

    db[ticker].find({}).sort({_id: 1}).forEach((element) => {
        if(last != undefined) {
            if(element._id - last._id > 60*1000) {
                for(let j=1;j<(element._id-last._id)/(60*1000);j++) {
                    rtn.push(last._id+(60*1000)*j);
                }
            }
        }

        last = element;
    });

    return rtn;
}
我能想到的唯一一件事是使用
$where
检查当前
\u id
是否在函数返回的
\u id
列表中,但我担心这将是不必要的资源浪费,因为它已经提供了我要查找的内容

MongoClient.connect(process.env.MONGO_URL, {
  useNewUrlParser: true,
  useUnifiedTopology: true
}, function(err, db) {
  let dbo = db.db('database');

  dbo.call(`fetchMissingDates('abcd')`, (error, result) => {});
});