want to create a subcollection in document in firebase when user sign up to app in react native its children subcollection created

want to add a subcollection when the user signs up to the app a subcollection is created to its document which contains its children.
here is my code:

    try {
    await firebase.auth().createUserWithEmailAndPassword(email, password);
    const currentUser = firebase.auth().currentUser;

    const db = firebase.firestore();
        email: currentUser.email,
        lastName: lastName,
        firstName: firstName,
      }).collection('users').doc(currentUser.uid).collection("recipient").add({name:"test", age:"25" }).then((data) => {
        console.log("Document has added")
    }).catch((err) => {
  } catch (err) {
    alert("There is something wrong!!!!" + err.message.toString());

Leave a Comment