Last active
September 14, 2021 16:05
-
-
Save vijayinyoutube/d0b033abb566b84c2c78325df35187ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FireStoreDataBase { | |
List studentsList = []; | |
final CollectionReference collectionRef = | |
FirebaseFirestore.instance.collection("Students"); | |
Future getData() async { | |
try { | |
//to get data from a single/particular document alone. | |
// var temp = await collectionRef.doc("<your document ID here>").get(); | |
// to get data from all documents sequentially | |
await collectionRef.get().then((querySnapshot) { | |
for (var result in querySnapshot.docs) { | |
studentsList.add(result.data()); | |
} | |
}); | |
return studentsList; | |
} catch (e) { | |
debugPrint("Error - $e"); | |
return e; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment