How to retrieve data from firestore by fields
How to get field level data from firebase?
I want values of certain field from all documents in a collection, What should I add? Heres my code,
Future<void> fetchAndSetData() {
FirebaseFirestore.instance
.collection('Reservations')
.get()
.then((value) {
print(value.docs.map((e) => e.data()));
});
}
and this is what I get in console
( 461): ({}, {seats: [104A, 104B], tableNo: 104})
Solution 1:
Changed the method like this
Future<void> fetchAndSetData() {
FirebaseFirestore.instance
.collection('Reservations')
.get()
.then((value) {
print(value.docs.map((e) => e['seats']));
});
}