How can I make a true or false command in mongodb and discord.js?

I’m trying to make a command where it updates a boolean in a specific server.

If someone types: !rating enable, it makes the “rating” section in the mongodb to true, and if they type: !rating disable, it makes the rating section false.

 if (!args[0]) return message.reply(`Usage: ${prefix} <enable/disable>`)

        if (args[0] === "enable") {

            Data.findOne({
                guildID: bot.guilds.cache.get(message.guild.id).id,
            }, (err, data) => {
                if (err) console.log(err);
                if (!data) {
                    const newData = new Data({
                        guildID: bot.guilds.cache.get(message.guild.id).id,
                        rating: true
                    })
                    newData.save().catch(err => console.log(err));
                    message.reply(`Rating was enabled, new setting saved.`)
                    if (data) {
                        const newData = new Data({
                            guildID: bot.guilds.cache.get(message.guild.id).id,
                            rating: true
                        })
                        newData.update({rating: args[0]}).catch(err => console.log(err));
                        message.reply(`Rating was enabled, setting updated.`)
                    }
                }
            })

            }

I want it so when someone does !rating enable it changes the mongodb to true.

Same thing, but if it’s !rating disable it changes the mongodb to false.

I want these to update everytime the server owner changes the rating.

My rating model:

const mongoose = require('mongoose')

const ratingSchema = mongoose.Schema({
    guildID: String,
    rating: Boolean
})

module.exports = mongoose.model("Rating", ratingSchema)

You acctualy don’t even need a model. All you need to do is, use find and replace.

The problem is the if (data) condition is inside the if (!data) block so it won’t run.

Also, both the message.reply for setting saved / updated are run before the result is known, they should run when save() or update() is resolved.