read static method
Implementation
static Future<dynamic> read(
{required String collection,
List<dynamic>? filters,
List<dynamic>? sorts,
int? limit,
Function? onSuccess,
Function? onError}) async {
filters ??= [];
sorts ??= [];
List<dynamic> data = [];
dynamic collectionRef = _filteredCollectionRef(
collection: collection, filters: filters, sorts: sorts);
if (limit != null) collectionRef = collectionRef.limit(limit);
await collectionRef.get().then((QuerySnapshot querySnapshot) {
if (querySnapshot.docs.isNotEmpty) data = querySnapshot.docs;
if (onSuccess != null) onSuccess(querySnapshot);
}).catchError((error) {
if (onError != null) onError(error);
});
return limit == 1 ? (data.isNotEmpty ? data[0] : null) : data;
}