0

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})
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Shanu
  • 311
  • 2
  • 16

1 Answers1

2

Changed the method like this

   Future<void> fetchAndSetData() { 
         FirebaseFirestore.instance
        .collection('Reservations')
        .get()
        .then((value) { 
 print(value.docs.map((e) => e['seats']));
 }); 
}
Dipak Prajapati
  • 116
  • 1
  • 4