I have a collection named categorymovie and each category contains a list of Movie
here now i want only list of all movies from each document’s field ‘movies’ from all category
here is firebase design
this is my function where i want to apply logic
void fetchMovieOnly() async {
List<Movie> allMovies = [];
final _db = FirebaseFirestore.instance;
final snapshot =
await _db.collection("MovieCategories").get();
//what code for fetching movies from querysnapshot
}
here is my movie class
class Movie {
String id;
String name;
Movie({required this.id, required this.name});
toJson() {
return {
'Id': id,
'Name': name,
};
}
factory Movie.fromMap(Map<String,dynamic> map){
return Movie(
id: map['Id'],
name: map['Name'],
);
}
}
2
Answers
you could do something like this