vendredi 26 juin 2020

How to create a firestore database?

// Add a new document in collection "schools"
db.collection("schools").doc("St. Francis Xavier's").set({
    Student1:
    {
        name: "Manoj",
        age: "21",
        address: "Tulunad"
    }
})
.then(function() {
    console.log("Document successfully written!");
})
.catch(function(error) {
    console.error("Error writing document: ", error);
});
  1. I want to create database of schools.
  2. For that I'll make a collection in Firestore database "schools" Inside that I need schoolname as doc
  3. And inside that I should be able to store different different students belonging to particular school But we can't do add operation on doc, we can only perform set operation.
  4. And while reading the data, I need basic data(for example name,class and address is enough) of all students belonging to all school ( not any particular) but all students and how to fetch that. And if I click on any particular student's name, then I should get entire data of that student.
  5. And one more is, I need to fetch names(schoolname doc) of all schools, and if I click on a single school name, then I need all data of students (for example name,class and address is enough) belonging to particular school. And if I click on any particular student's name, then I should get entire data of that student. And also how to update the data of a particular student who belongs to particular school. For example i want to update age of a particular student who belongs to a particular school. (Please give me the syntax for these..., Thank You)



Aucun commentaire:

Enregistrer un commentaire