getApprovedPostsQuery method

Query<PostModel> getApprovedPostsQuery(
  1. {void converterCallback(
    1. PostModel
    )?}
)

Returns a stream of approved posts to show in the Feed.

Implementation

Query<PostModel> getApprovedPostsQuery({
  void Function(PostModel)? converterCallback,
}) =>
    instance
        .collection('posts')
        .where('approved', isEqualTo: true)
        .orderBy('postDate', descending: true)
        .withConverter(
          fromFirestore: (snapshot, _) {
            final data =
                PostModel.fromJsonAndId(snapshot.data()!, snapshot.id);
            if (converterCallback != null) converterCallback(data);
            return data;
          },
          toFirestore: (_, __) => {},
        );