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

161
Vistas
Mongoose update nested objects on multiple documents

Here is the schema:

var user = new Schema ({
    name: {type:String},
    lastName:  {type:String},
    extraInfo: {
        phone: {type:String},
        age: {type: Number}
    },
    postalCode: {type:Number}
})

Let's assume we have 10 documents with that schema and 5 of them have postalCode '12345'.

How can I select all of them and update the extraInfo.phone and extraInfo.age of these documents?

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

0

Well, i dont have a database at hand, to try it out, but it should be something like this.

db.User.update(
    {postalCode: 12345}, 
    {"extraInfo.phone": value1, "extraInfo.age": value2},
    {multi: true});
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