filterTableRows method

Future<List> filterTableRows({
  1. required String tableName,
  2. required String filter,
  3. int top = 20,
  4. List<String>? fields,
})

Get a list of all tables in storage account top: Optional. Returns only the top n tables or entities from the set. The package defaults this value to 20. filter: Required. Logic for filter condition can be gotten from official documentation e.g RowKey%20eq%"237" or AmountDue%20gt%2010. fields: Optional. Specify columns/fields to be returned. By default, all fields are returned by the package

Implementation

Future<List<dynamic>> filterTableRows({
  required String tableName,
  required String filter,
  int top = 20,
  List<String>? fields,
}) async {
  String selectParams = _resolveNodeParams(fields);
  String path = 'https://${config[accountName]}.table.core.windows.net/$tableName()?\$filter=$filter&\$select=$selectParams&\$top=$top';
//    print('path to upload: $path'); //DEBUG LOG
  var request = http.Request('GET', Uri.parse(path));
  request.headers['Accept'] = 'application/json;odata=nometadata';
  request.headers['Content-Type'] = 'application/json';
  request.headers['Accept-Charset'] = 'UTF-8';
  request.headers['DataServiceVersion'] = '3.0;NetFx';
  request.headers['MaxDataServiceVersion'] = '3.0;NetFx';
  _sign4Tables(request);
  var res = await request.send();
  var message = await res.stream.bytesToString();
  if (res.statusCode == 200) {
    List<dynamic> tabList = [];
    var jsonResponse = await jsonDecode(message);
    for (var tData in jsonResponse['value']) {
      tabList.add(tData);
    }
    return tabList;
  }
  throw AzureStorageException(message, res.statusCode, res.headers);
}