We are trying add documents values manually using react native app to firestore DB.
Here is the reference code we found for web
db.collection("cities").doc("LA").set({
    name: "Los Angeles",
    state: "CA",
    country: "USA"
})
.then(function() {
    console.log("Document successfully written!");
})
.catch(function(error) {
    console.error("Error writing document: ", error);
});
For react native we used this code
firebase.firestore().collection('users').doc("hello").add({
        title: this.state.textInput,
        complete: false,
      })
I'm getting error like add us not defined
How to add documents and collections to it ?
You can add a document to a collection. You cannot add a document to a document.
To add a document to your users collection:
firebase.firestore().collection('users').add({
  title: this.state.textInput,
  complete: false,
})
So remove the .doc("hello") from there.
Here I found the solution for my data structure
firebase
  .firestore()
  .collection("Users")
  .doc("mydoc")
  .collection("Activities")
  .doc("Database")
  .set({
    key: "1",
    value: "",
  })
  .then((ref) => { console.log(ref) });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With