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

372
Vistas
Firestore nested maps (object), dot notation doesn't work

I have a nested maps on Firestore, I am trying to update an object into another object using dot notation but it's concatenate the called key with object name in Firestore, if I update this nested map (object) without dot notation, will overwrite the entire map field.

if (doc && doc.exists) {
        await doc.ref.update({subscription: {chartslab: {
          "options.expiration": new Date(new Date()
              .getTime()+(10*24*60*60*1000)),
          "options.updatedAt": new Date().toISOString(),
        }}}).then(() => {
          return res.status(200).send("Document successfully updated!");
        });
      } else {
        await doc.ref.set({subscription: {chartslab: {options: {
          expiration: new Date(new Date().getTime()+(5*24*60*60*1000)),
        }}}});
        return res.status(200).send("Done");
      }

Create

Create Firestore data

Update

Update Firestore data

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

0

If you are using dot notation to update nested field, you must add the complete path in dot notation as shown below:

await doc.ref.update({
  'subscription.chartLabs.options.expiration': 'value',
  'subscription.chartLabs.options.updatedAt': 'value'
})

There's a package flat which can be useful in this case if you have a lot of nested fields to be updated.

const flatten = require('flat');

const updateObj = flatten({
  subscription: {
    chartLabs: {
      options: {
        expiration: '...',
        updatedAt: '...'
      }
    }
  }
})

Since you are updating the whole 'options' object, you can try this:

await doc.ref.update({
  'subscription.chartLabs.options': {
    expiration: '...',
    updatedAt: '...'
  }
})
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