aggregate method

Future<List<Map<String, dynamic>>> aggregate(
  1. String collection,
  2. List<Map<String, dynamic>> pipeline
)

Runs an aggregation pipeline

Implementation

Future<List<Map<String, dynamic>>> aggregate(
  String collection,
  List<Map<String, dynamic>> pipeline,
) async {
  final response = await _client.post(
    Uri.parse('$baseUrl/collections/$collection/aggregate'),
    headers: _headers,
    body: jsonEncode({'pipeline': pipeline}),
  );

  final data = _handleResponse(response);
  final results = data['results'] as List? ?? [];
  return List<Map<String, dynamic>>.from(results);
}