【发布时间】:2022-08-16 00:08:19
【问题描述】:
我不知道如何从 100 中减去 50 使用sequelize mysql。 什么。我该怎么做?
var us = await User.findOne({ where: { userID: ctx.from.id } })
await us.update({balance: -50?})
标签: javascript mysql node.js sequelize.js
我不知道如何从 100 中减去 50 使用sequelize mysql。 什么。我该怎么做?
var us = await User.findOne({ where: { userID: ctx.from.id } })
await us.update({balance: -50?})
标签: javascript mysql node.js sequelize.js
您可以在更新时在代码中引用当前余额:
var us = await User.findOne({ where: { userID: ctx.from.id } })
await us.update({balance: (us?.balance ?? 0) - 50})
【讨论】: