javascript - Fiber 中的空变量

标签 javascript node.js meteor

所以,我有一个已正确初始化的 fields 变量。我的目标是在 Fiber 中使用它。这是代码:

console.log(fields); //<--- Here it's OK
Fiber(function () {
    var qry = Connections.findOne({login:fields[1]});
    if (typeof(qry) === 'undefined') {
        console.log('INSERT');
        console.log(fields); //<--- Here, the variable "fields" is empty
        Connections.insert({
            login: fields[1],
            ip: fields[2],
            created_at: Date.now(),
            updated_at: Date.now(),
        });
    } else {
        console.log("UPDATE");
    }
}).run();

如何将变量fields的内容传递到Fiber中?

提前致谢。

最佳答案

这个应该可以工作:

var fields = /* whatever */;

Fiber(function (fields) {
  // ...
}).run(fields);

如果您想了解更多相关信息 look here .

关于javascript - Fiber 中的空变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25212428/

相关文章:

javascript - GAS按钮或输入[提交]保持刷新页面?为什么?

javascript - 为什么 Array.prototype.map()、Array.prototype.forEach() 和 For-In 循环对 Array.fill() 给出错误的结果?

node.js - socket.io 是如何工作的

node.js - npm ci 在 Windows : node-gyp rebuild 上输出 Angular 8 和 Node 12 的错误

javascript - 将参数传递给 Blaze 模板

javascript - 在 Passport.authenticate() 内部重定向时出现问题

javascript - 将相同的参数应用于函数列表,并在每个结果之间执行操作

javascript - 为什么 child_process.execSync 的输出为空?

javascript - Meteor.user() 和 localStorage.getItem ('Meteor.userId' )返回 null

Meteor 文件上传不工作