Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Modificar arreglos en Firebase Firestore

La base de datos de Firestore tiene la siguiente estructura de campo

 images: {day: ['url1', 'url2', 'url3,] night: ['url1']}

Primero, me gustaría poder agregar un valor a las matrices. Intenté lo siguiente:

 await updateDoc(doc(firestore, FIRSTORE_COLLECTIONS.IMAGES, id), { [folder]: { [key]: arrayUnion(fileUrl) }

Fue a las imágenes correctas: ruta pero desafortunadamente esto solo creó una nueva matriz con un valor y eliminó las que estaban allí.

En segundo lugar. Si también me gusta poder crear una nueva matriz en la misma ruta con una clave que no existe, ¿se puede hacer esto y cómo podría resolverse con esta configuración? ¿Alguna idea?

dependencias: "firebase": "^9.1.1", "reaccionar": "^17.0.2"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto es lo que lo resolvió:

 await updateDoc(ref, { [`${folder}.${key}`]: arrayUnion(fileUrl) });

Ruta adecuada donde se implementan los métodos arrayUnion. También crea una nueva matriz si la clave no existe, lo cual es bueno.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!