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

89
Vistas
Mongoose Array Field Can't Updating

Here is my schema;

...
  group: [
    {
      type: mongoose.Types.ObjectId,
      ref: 'groups'
    }
  ],
...

I'am trying update data. I can update other fields but I can not update group field. My given data;

{
  name: 'John Wick',
  role: '631c8f39fb0d6300ebf2d0c1',
  group: [ '632c770cdabb9fbf70a84efa', '632c76e26fec98665363cc43' ]
}

Name and Role can update but group is not. What should I do?

Edit: Here is my update code;

User.findOneAndUpdate({_id},{{
  name: 'John Wick',
  role: '631c8f39fb0d6300ebf2d0c1',
  group: [ '632c770cdabb9fbf70a84efa', '632c76e26fec98665363cc43' ]
}},{}, (err,doc) => err ? console.log(err) : null)
almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You have double {{ in the second argument of the query. That should be changed with single {:

User.findOneAndUpdate({ _id }, {
  // Data
})
``
almost 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