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

112
Views
How do I make sure null and empty string fields arent added to my documents in firestore Reactjs

I am adding objects to a document and I want to make sure empty strings and null instances don't add fields as I only want to create fields once they have been actually added

 await updateDoc(itemRef,
 {thing: '3232',
    thing2: null,
    thing3:'' });
    }

how do I make sure only thing: 3232 is in the new document and the best way to go about it?

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

0

Probably easiest to just write a function that filters the property keys based on value:

function filterInPlace(obj) {
    for (const [key, value] of Object.entries(obj))
        if (obj[key] == null || obj[key] == '')
            delete obj[key]
}
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!