Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda