count method

Future<int> count(
  1. String collection, {
  2. Map<String, dynamic>? filter,
})

Counts documents

Implementation

Future<int> count(
  String collection, {
  Map<String, dynamic>? filter,
}) async {
  final response = await _client.post(
    Uri.parse('$baseUrl/collections/$collection/count'),
    headers: _headers,
    body: jsonEncode({
      if (filter != null) 'filter': filter,
    }),
  );

  final data = _handleResponse(response);
  return data['count'] as int? ?? 0;
}