hello I have a discord bot and I started to do a marriage and divorce command the case is that when I try to delete the user from the db I get the error
DocumentNotFoundError: No document found for query "{ _id: new ObjectId("61ec3c66cb5991d616c6032d") }" on model "casados"
this is my model
const mongoose = require("mongoose")
const casados = mongoose.Schema({
pareja1: String,
pareja2: String
})
module.exports = mongoose.model("casados", casados)
my code in the marry command is
look for the model
let modelo = await casados.findOne({ $or: [{pareja1: interaction.user.id}, {pareja2: interaction.user.id}]})
If it doesn't find it, create a new one.
if(!modelo) modelo = new casados({
pareja1: interaction.user.id,
pareja2: pareja.id
})
await modelo.save()
then on my command divorce
look for the model again
let modelo = await casados.findOne({ $or: [{pareja1: interaction.user.id}, {pareja2: interaction.user.id}]})
and delete it
await casados.findOneAndDelete({
$or: [
{pareja1: interaction.user.id},
{pareja2: interaction.user.id}
]}).catch(e=> { console.log(e)})