node loopback updateAll 更新 属性 为另一个 属性 值
node loopback updateAll update property with another property value
我正在尝试调用节点环回 updateAll 方法,其中一个 属性 接收另一个 属性 的值。我该怎么做?
Model.updateAll(
{
Status: 'Cancel',
},
{
Qty: 0
QtyCancelled: Qty <------------- How I should write this line?
},
function(err, info) {
console.log('result',info);
}
);
}
提前致谢,
LoopBack 不支持其中一个 属性 接收从数据库读取的值 and/or 更新命令中的其他属性的更新。
如果您使用的是 SQL 数据库,那么您可以 运行 直接 SQL 查询。
Model.dataSource.connector.execute(
'UPDATE Model SET Qty=?, QtyCancelled=Qty WHERE Status = "Cancel"',
[0],
function (err, info) {
// ...
});
见https://loopback.io/doc/en/lb3/Executing-native-SQL.html
许多没有-SQL 的连接器也支持execute
API,请查看您正在使用的连接器的文档。
我正在尝试调用节点环回 updateAll 方法,其中一个 属性 接收另一个 属性 的值。我该怎么做?
Model.updateAll(
{
Status: 'Cancel',
},
{
Qty: 0
QtyCancelled: Qty <------------- How I should write this line?
},
function(err, info) {
console.log('result',info);
}
);
}
提前致谢,
LoopBack 不支持其中一个 属性 接收从数据库读取的值 and/or 更新命令中的其他属性的更新。
如果您使用的是 SQL 数据库,那么您可以 运行 直接 SQL 查询。
Model.dataSource.connector.execute(
'UPDATE Model SET Qty=?, QtyCancelled=Qty WHERE Status = "Cancel"',
[0],
function (err, info) {
// ...
});
见https://loopback.io/doc/en/lb3/Executing-native-SQL.html
许多没有-SQL 的连接器也支持execute
API,请查看您正在使用的连接器的文档。