table method

Future<List<Map>> table(
  1. String cube,
  2. List<String> columns, {
  3. List<String>? indices,
  4. Map<String, dynamic>? filters,
})

Flat iterable records of cube.

Indices are returned as column caring the index name

Implementation

Future<List<Map>> table(String cube, List<String> columns,
    {List<String>? indices, Map<String, dynamic>? filters}) async {
  final response = await dio.put('/cube/table/$cube', data: {
    'columns': columns,
    'indices': indices,
    'filters': filters,
  });
  final data = response.data as List<Map>;

  final datasources = await _prepare(cube, columns);

  for (var item in data) {
    for (var axis in columns) {
      item['${axis}Label'] = datasources[axis]![item[axis]] ?? item[axis];
    }
  }

  return data;
}