getTableDataFromWhere method

dynamic getTableDataFromWhere(
  1. dynamic tableName,
  2. dynamic where,
  3. dynamic context,
  4. dynamic onlyOne,
  5. int futureSeq,
)

Implementation

getTableDataFromWhere(tableName, where, context, onlyOne, int futureSeq) {
  myLogAll('getTableDataFromWhere');
  //filter the table data by where condition
  myLog('getTableDataFromWhere $tableName, where: $where');
  var tableInfo = _tableList[tableName];

  if (isNull(tableInfo)) {
    /*Future.delayed(const Duration(seconds: 1), () {
      retrieveTableFromDB(tableName, context, futureSeq);
    });*/
    retrieveTableFromDB(tableName, where, context, futureSeq);
    return null;
  }
  List result = [];
  if (!isNull(tableInfo)) {
    List data = getTableData(tableName, context);
    List whereList = where.toString().split(' and ');
    Map tableWhereList = getTableWhereList(whereList, '=');
    _tableList[tableName]?[gWherelist] = tableWhereList;
    for (dynamic dataRow in data) {
      /*for (var keyValue in mapWhere.entries) {
        if (dataRow[keyValue.key] != keyValue.value) {
          isMatch = false;
          break;
        }
      }*/

      bool isMatch = isDataWhereMatch(dataRow, whereList);
      if (isMatch) {
        if (onlyOne) {
          return dataRow;
        }
        result.add(dataRow);
      }
    }
  }
  return result;
}