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

213
Vistas
$pull data from a double nested schema

from the below schema ,

how do i delete out one specific answer comment ??


const Schemaa = mongoose.Schema({
  
    questionBody: String,
    Comment:[{
       commentBody: String,   
    }],
    answer: [{
        answerBody: String,
        Comment:[{
            commentBody:String,    /// i want to delete one specific comment having a unique
        }]                         ///  'Object _id.
    }]
})
export default mongoose.model("Questions", Schemaa)

I used the below code, to Add a comment in answers section and it worked fine...


const updatedQuestion = await Schemaa.updateOne(
            { 'answer._id' : answerId},              /// I passed that specific answer's _id   
            { $push: {                               ///  as answerId
           "answer.$.Comment": { 
             commentBody}
            } 
           })

regards.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

caught the error, its working with this now...


await Questions.updateOne(
            { 'answer._id': answerId},{
                $pull:{
                    'answer.$.Comment' : { '_id' :commentId}
                }
            }
        )

over 4 years ago · Santiago Trujillo Denunciar
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