THp*_*ubs 8 javascript typescript
在我的代码中,我有一个用户名数组。我试图通过每个名称,检查用户是否存在于数据库中并创建用户。问题是,我的短绒'await' has no effect on the type of this expression
在我标记的地方说:
await Promise.all(
userNames.map(async userName => {
const user = await users.findOne({ name: userNames });
if (!user)
await users.create({ // Linter marks this bracket (Not the curly bracket)
name: userName,
}); // And this end bracket
}),
);
Run Code Online (Sandbox Code Playgroud)
我的编辑建议是这样的:
if (user) {
return;
}
await users.create({
name: userName,
});
Run Code Online (Sandbox Code Playgroud)
翻转 if else。知道为什么吗?
归档时间: |
|
查看次数: |
14680 次 |
最近记录: |