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

155
Views
Guardar la identificación del documento al momento de crear un documento en Firebase v9 usando React JS

Hola quiero que al crear un nuevo documento, donde dice "projectId" se pase al campo "projectId" el id del documento que se genera automáticamente, ¿es esto posible?

ingrese la descripción de la imagen aquí

Este es mi código:

 addDoc(collection(db, "projects"), { name: project, uid: currentUser, projectId: 'here the proyectId that i dont know how to pass it' })

Estoy usando Firebase v9 Modular, Firestore y React JS

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

0

Lo siguiente hará el truco:

 import { collection, doc, setDoc } from "firebase/firestore"; // Add a new document with a generated id const newDocRef = doc(collection(db, "projects")); // Set the doc, using the id property of the DocumentReference await setDoc(newDocRef, { name: project, uid: currentUser, projectId: newDocRef.id } );
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!