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

169
Views
How to create a new collection on document creation if one doesn't exist (Firebase 9 & NextJS)

Basically I am wanting to create a new collection on a document creation if that said collection does not exist.

Here is the structure I have

-Company (Collection)

--Company Name (Doc)

---CompanyInfo (Doc)

---Users (Collection)

----Users (Docs)

This is working if I create the collection manually in firebase, but I want these to somehow create automatically when a company signs up

Here is my full code: https://pastebin.com/JeCAM3Fx

const handleCreate = (e) => {
    e.preventDefault();
    createUserWithEmailAndPassword(auth, email, password)
        .then((userInfo) => {
            setDoc(doc(db, `company/${company}/users`, userInfo.uid), {
                firstName,
                lastName,
                email,
                phone,
                address,
                country,
                state,
                company,
                position,
            });
            console.log("You are registerd!");
        })
        .catch((error) => {
            console.log(error.message);
        });
};

I get the error cannot find indexOf() when trying to signup

I am using NextJS and Firebase 9

about 4 years ago · Juan Pablo Isaza
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!