loopbackjs - 环回的 upsertWithWhere() 中的问题
问题描述
我正在使用loopback3.x。为什么 upsertWithWhere 函数总是更新同一个实例?当 updateWithWhere 函数执行时,始终只有一个实例。
app.models.oneTimePassword.upsertWithWhere({
where: {
userId: user.id
}
}, {
userId: user.id,
otp: otp,
updatedAt: updatedAt,
type: 'email'
}, (err, res) => {
if (!err) {
callback(null, {
status: "OK",
message: "email sent"
});
} else {
callback(err);
}
});
解决方案
app.models.oneTimePassword.upsertWithWhere(
{
userId: user.id
},
{
userId: user.id,
otp: otp,
updatedAt: updatedAt,
type: 'email'
},
(err, res) => {
if (!err) {
callback(null, {
status: "OK",
message: "email sent"
});
} else {
callback(err);
});
试试这个,第一个参数upsertWithWhere
应该是where
因此,你不需要添加where: {}
查看这个官方文档
推荐阅读
- python - 蟒蛇处理。为什么背景(0,0,0)不会在我的形状上绘制?
- python - 为什么循环时程序中没有定义屏幕?
- java - Mockito 区分歧义 any() 集合与列表
- python - linux debian 9中thingsboard-gateway包安装程序的依赖问题
- vue.js - Vue:对 v-for 中输入数组的输入变化做出反应
- python - 在 tkinter 的弹出窗口中动态创建条目小部件时出现问题
- ruby-on-rails - rufus-scheduler 只用 puma 执行一次 rake 任务
- mysql - SQL 使用 csv 源路径创建表
- c++ - JsonCpp:如何将 unordered_map 转换为 Json::Value
- windows - 是否存在与 SID 1:1 映射的可读 Windows 用户帐户 ID?