getAll method

Future<List<Map<String, Object?>>> getAll({
  1. SelectorBuilder? selector,
  2. Map<String, Object?>? filter,
  3. FindOptions? findOptions,
  4. String? hint,
  5. int? skip,
  6. Map<String, Object>? sort,
  7. int? limit,
  8. Map<String, Object>? hintDocument,
  9. Map<String, Object>? projection,
  10. Map<String, Object>? rawOptions,
})

Implementation

Future<List<Map<String, Object?>>> getAll({
  SelectorBuilder? selector,
  Map<String, Object?>? filter,
  FindOptions? findOptions,
  String? hint,
  int? skip,
  Map<String, Object>? sort,
  int? limit,
  Map<String, Object>? hintDocument,
  Map<String, Object>? projection,
  Map<String, Object>? rawOptions,
}) async {
  skip ??= 0;
  skip = skip < 1 ? null : skip;

  var results = <Map<String, Object?>>[];
  var result = collection.modernFind(
    selector: selector,
    filter: filter,
    findOptions: findOptions,
    hint: hint,
    skip: skip,
    sort: sort,
    limit: limit,
    hintDocument: hintDocument,
    projection: projection,
    rawOptions: rawOptions,
  );

  List<String>? selectedFields;
  if (selector != null && selector.paramFields.isNotEmpty) {
    selectedFields = selector.paramFields.keys.toList();
  }

  await result.forEach((element) {
    results.add(toModel(element, selectedFields: selectedFields));
  });

  return results;
}