【发布时间】:2021-06-22 17:13:30
【问题描述】:
忽略乱码。我已经连续工作了好几个小时,还没有时间组织它。
每次 messageCount 为 100 或更多时,我都会收到此错误。
const profileData = await Profiles.findOne({
userID: message.author.id
});
if (!profileData) return console.log('re')
try {
if (profileData.messageCount >= 100) {
console.log('yeet')
await Profiles.updateMany({
userID: message.author.id
}, {
messageCount: 0,
}, {
$inc: {
caseCount: +1
}
}, {
upsert: true
});
} else {
console.log('na')
}
} catch (error) {
console.log(error);
}
【问题讨论】:
-
我不确定为什么
updateMany()函数中有 4 个对象而不是 3 个对象。我相信你的意思是把$set:放在{ messageCount: 0, },之前