getCollectionwithParams<Model extends BaseModel> method

  1. @override
Future<List<Model>> getCollectionwithParams<Model extends BaseModel>(
  1. String path, {
  2. List<QueryType>? where,
  3. Map<String, bool>? orderby,
  4. int? limit,
  5. String? startAfterID,
})
override

Implementation

@override
Future<List<Model>> getCollectionwithParams<Model extends BaseModel>(
    String path,
    {List<QueryType>? where,
    Map<String, bool>? orderby,
    int? limit,
    String? startAfterID}) async {
  var pathParam = path.split("/");

  if (pathParam.length.isEven) {
    throw GetCollectionGroupError(
        "number of ids must be less than paths for subcollection",
        StackTrace.current);
  }

  if (where != null) {
    where = checkQueryConstructor(where);
  }

  try {
    DocumentSnapshot? startAfter;
    if (startAfterID != null) {
      // startAfter = await firestoreRef(path, startAfterID).get();
    }

    var collection = collectionPath(pathParam);

    var collectionReference = queryConstruction(collection,
        where: where, orderby: orderby, limit: limit, startAfter: startAfter);
    var query = await collectionReference.get();
    return parser.parse<Model>(query);
  } catch (err, s) {
    throw CollectionWithParamsError(err.toString(), s);
  }
}