我编写了一个在循环(映射)中调用的函数,并且该函数使用了 Promise。现在,我希望该函数同步运行并在调用其下一个实例之前退出。
function t1(){
let arr1 = [1,2,3,4,5];
return Promise.map(arr1, (val) =>{
const params = {
"param1" : val1
};
return t2(params);
});
}
function t2(event){
return Promise.resolve()
.then({
//do something
//code doesn't reach here in sync manner. all five instance are invoked and then code reaches here for first instance and so on
})
.then({
//promise chaining. do something more
})
}Run Code Online (Sandbox Code Playgroud)
t2 被调用五次,但我希望每个实例只在实例返回值之前调用。目前它的行为不是那样,而是并行调用该函数五次。
由于项目限制,我无法使用 async/await。
我正在尝试使用节点 db.updateItem(query) 更新 was dynamoDB 中的项目。
我收到以下错误:
Invalid UpdateExpression: Expression size has exceeded the maximum allowed size dynamodb
Run Code Online (Sandbox Code Playgroud)
在阅读了几篇文章后,我意识到 dynamoDB 允许 itemSize 为 400KB,这可能是一个问题。但如果这是问题所在,为什么它首先允许插入项目。
我不确定到底是什么问题。任何帮助,将不胜感激。
如果我错过了任何必需的信息,请告诉我