Javascript 在同一输入中传输不同输入时运行并行功能

Javascript 在同一输入中传输不同输入时运行并行功能,javascript,node.js,async.js,Javascript,Node.js,Async.js,我正在尝试使用async.js运行并行函数 但当我尝试更新数据库的行时,异步函数不会处理不同的输入。 它为where零件更新相同的值,该零件始终只更新一条记录。如何将同一函数的并行运行的局部变量转换为不同的变量 这是我的代码: exports.run_mercadolibre_jobs = function() { var Model = require('../../models/index').Model; var async = require("async");

我正在尝试使用async.js运行并行函数

但当我尝试更新数据库的行时,异步函数不会处理不同的输入。 它为where零件更新相同的值,该零件始终只更新一条记录。如何将同一函数的并行运行的局部变量转换为不同的变量

这是我的代码:

exports.run_mercadolibre_jobs = function() {

    var Model  = require('../../models/index').Model;
    var async = require("async");


    var values = {
                attributes: ['environment_hash'],
                raw: true
        };

        Model
            .findAll(values)
            .then(function(accounts) {
                async.map(accounts, function (account) {
                    module.exports.refresh_access_token(account.environment_hash);
                });           
          });

}



exports.refresh_access_token = function(environment_hash) {

    ...

    var env_hash = environment_hash;
    where = { environment_hash: env_hash };

    Model.findOne({where: where}).then(function (account) {
        if (!account) {
            // Item not found, create a new one


        } else {
            // Found an item, update it


            values = {
              refresh_token: body.refresh_token,
              expires_in: expires_in

            };

                        Model.update(values, {where: where})
                            .then(function () {
                                console.log('updated!');
                            })
                            .catch(function (err) {
                                console.log('error on update');
                            });

                }
            });





        }
    });



}

看看代码,问题不太可能出在异步函数上。在我看来,您只需执行accounts.forEach(函数(account){refresh\u access\u token(account.environment\u hash)})仍然会得到相同的结果。请尝试console.log envirorment\u散列变量,并检查它是否每次都打印相同的结果