如何在mongoose中删除一个模型的单个值


const { model, Schema } = require('mongoose');
module.exports = model(
'Profile',
new Schema({
userId: String,
guildId: String, 
daily: Number,
weekly: Number,
monthly: Number,
total: Number,
cooldown: Date
})
);

这是我的猫鼬模型,我如何删除所有值"daily">

试试这个:

Profile.updateMany({}, { $unset: { daily: 1 } })

最新更新