Node.js 对节点中数组中的每个对象调用函数

Node.js 对节点中数组中的每个对象调用函数,node.js,mongoose,es6-promise,Node.js,Mongoose,Es6 Promise,我正在尝试批处理一个数据库更新以重新填充mongo集合。我创建了一个对象来保存从外部源查找数据所需的属性,然后将其添加回MongoDb集合 该数组如下所示: const pops = [ { table: 'SFAccounts', label: 'Account__c', createListName: 'Accounts' }, { table: 'SFTimes', label: 'CusTime__c', cr

我正在尝试批处理一个数据库更新以重新填充mongo集合。我创建了一个对象来保存从外部源查找数据所需的属性,然后将其添加回MongoDb集合

该数组如下所示:

const pops = [ 
    { table: 'SFAccounts',
      label: 'Account__c', 
      createListName: 'Accounts'
    },
    { table: 'SFTimes',
      label: 'CusTime__c', 
      createListName: 'Time'
    }]
然后我想创建一个函数,它接受“table”、“label”和“createListName”,它基本上是这样做的

async function processData(table, label, createListName) {
    // Get some info from Salesforce 
    const dataFromSF = await getMetaDataFromSalesForce(table)
    // Extract the parts I actually need
    const relevantBits = dataFromSF.filter(field => field.name === label)
    //Create a new list in the db
    const createResult = await List.create( { name: createListName, values: relevantBits } )
    return createResult
}
最终目标是达到以下目标:

await Promise.all(processData(pops))

将等待所有表被拉入并填充到数据库中。

如果更改processData的参数:

async function processData({table, label, createListName}) {
    // Get some info from Salesforce 
    const dataFromSF = await getMetaDataFromSalesForce(table)
    // Extract the parts I actually need
    const relevantBits = dataFromSF.filter(field => field.name === label)
    //Create a new list in the db
    const createResult = await List.create( { name: createListName, values: relevantBits } )
    return createResult
}

它只是在等待Promise.allpops.mapprocessData

wait Promise.allpops.map{table,label,createListName}=>processDatatable,label,createListName;对节点中数组中的每个对象调用函数-您的问题是如何做到这一点?我没有看到任何其他的东西,我最终实现了这一点,但我没有想到将对象直接分解为变量名,这是一个伟大的发现!谢谢