Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

238
Vistas
DocumentNotFoundError: No document found for query"{id:xxx}"

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)})
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda