tmw*_*wrp 2 mongoose mongodb node.js mongodb-query
所以我有这个功能:
async function update_subscription_status(id) {
await User.updateOne({chat_id: id}, {
mailing: // need to change this boolean field to its opposite
})
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以在更新之前不检查其状态吗?
$eq返回 true 或 false
async function update_subscription_status(id) {
await User.updateOne(
{ chat_id: id },
[ { "$set": { "mailing": { "$eq": [false, "$mailing"] } } } ]
)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1567 次 |
| 最近记录: |