fetchCollection method

Future<CollectionFetched> fetchCollection(
  1. String type, {
  2. Map<String, String> headers = const {},
  3. Map<String, String> query = const {},
  4. Map<String, String> page = const {},
  5. Map<String, String> filter = const {},
  6. Iterable<String> include = const [],
  7. Iterable<String> sort = const [],
  8. Map<String, Iterable<String>> fields = const {},
})

Fetches a primary collection of type type.

Optional arguments:

  • headers - any extra HTTP headers
  • query - any extra query parameters
  • page - pagination options
  • filter - filtering options
  • include - request to include related resources
  • sort - collection sorting options
  • fields - sparse fields options

Implementation

Future<CollectionFetched> fetchCollection(
  String type, {
  Map<String, String> headers = const {},
  Map<String, String> query = const {},
  Map<String, String> page = const {},
  Map<String, String> filter = const {},
  Iterable<String> include = const [],
  Iterable<String> sort = const [],
  Map<String, Iterable<String>> fields = const {},
}) async {
  final response = await send(
      baseUri.collection(type),
      Request.get()
        ..headers.addAll(headers)
        ..query.addAll(query)
        ..page(page)
        ..filter(filter)
        ..include(include)
        ..sort(sort)
        ..fields(fields));
  return CollectionFetched(
      response.http, response.document ?? (throw FormatException()));
}