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

128
Vistas
Update an item inside a document's array

I have a model that looks like this:

const List = new Schema({
    name: { type: String, unique: true, required: true, dropDups: true },
    cards: [{ type: Schema.Types.ObjectId, ref: 'Card' }],
    orderItems: [{ value: Number, card: { type: Schema.Types.ObjectId, ref: 'Card' } }]
});

And a document base of that model that looks like this:

{ _id: ObjectId: ("1234567890"), cards: [...], OrderItems: [{ card: ObjectId: ("0987654321"), value: 1.1, _id: ObjectId: ("1029384756") }] }

I want to update the value of the only object that's in the OrderItem's array of my document, I tried the most obvious methods like:

doc.OrderItems[0].value = 1.2;
doc.save();

but that's not working, how can I do it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Turns out that the method I was using was correct, the issue was when I was calling the parameters in my server function trough my endpoint

about 4 years ago · Juan Pablo Isaza 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