Alk*_*Alk 3 javascript sql node.js express sequelize.js
我有以下功能,用于更新用户个人资料图片的 URL -
const updateProfilePic = async (req, res) => {
const userId = req.param("id");
if (userId) {
const targetPath = `...`;
User.update(
{
profilePic: targetPath
},
{ where: { id: userId }, returning: true }
)
.then(updatedUser => {
console.log(updatedUser);
res.json(updatedUser);
})
.catch(error => {
console.log(error);
res.status(400).send({ error: error });
});
}
};
Run Code Online (Sandbox Code Playgroud)
这将成功更新数据库 - 但是作为用户数据而不是then获取- 如果我删除该标志,它只会返回. 我不确定我做错了什么 - 我正在尝试获取用户对象,以便我可以将其传递给客户端。[ undefined, 1 ]updatedUserreturning : true[ 1 ]
| 归档时间: |
|
| 查看次数: |
2393 次 |
| 最近记录: |