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

178
Views
react firebase add new document to collection

I want to remove every value-field from the document "view-count" in the "server-details" collection in react with firebase. Currently I am deleting the document with deleteDoc() but I can't figure out how to create the document again. Here is my code:

    const resetViewCounter = async () => {

        const valueDoc = doc(database, "server-details", "view-count");
        await deleteDoc(valueDoc);
        await addDoc(valueDoc);

        // window.location.reload(false); // temporarily
    }

Thanks for your help!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think you're looking for setDoc(valueDoc.ref, {}).

But I'd recommend actually deleting the specific fields, with FieldValue.delete as shown in the documentation on deleting fields.

about 4 years ago · Santiago Trujillo 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!