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

269
Vistas
How do I pull an ObjectId from array in Mongoose document?

I want to pull (remove) an ObjectId from an array in a Mongoose document, but it isn't removed. The code is like this

UserModel.updateOne({ _id: author._id }, {
    $pull:
        { snippets: { _id: ObjectId(snippet._id) } }
  })

The author._id is the ID of the particular user of the UserModel. snippets is an array of ObjectId's referring to another schema. snippet is the document whose ObjectId I want to remove from the array.

I think I have made it clear what I want, but the ObjectId is not removed from the array, which I can see in the database.

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