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

280
Vistas
How to save an Array with objects using markModified? / Mongoose
owningCharacters = [object1, object2, object3]

My DB has an array and it has multiple objects.

owningCharacters [Array]

0: Objects {}

1: Objects {}

2: Objects {}

I edited an object's value and saved it like this.

owningCharacters[0].level++;
for(let i = 0; i < user.owningCharacters.length ; i++){
   user.markModified("owningCharacters");
};
user.save();

but DB didn't save the edited value. So I also tried like this too.

for(let i = 0; i < user.owningCharacters.length ; i++){
   user.markModified("owningCharacters." + i);
};
user.save();
for(let i = 0; i < user.owningCharacters.length ; i++){
   user.markModified(i);
};
user.save();

And these tries didn't work either.

How can I save every single objects in an Array?

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