fetchRecords method

Future<Map<String, dynamic>> fetchRecords({
  1. String condition = "",
  2. String fetchMode = "LIST",
  3. String limitCondition = "",
})

Implementation

Future<Map<String,dynamic>> fetchRecords({String condition = "",String fetchMode = "LIST",String limitCondition = ""}) async {
  Map<String,dynamic> result = {
    "status": "failure",
    "message": "nothing executed",
    "operation": "SELECT"
  };
  try {
    String query = "SELECT * FROM " + getSelectQuery();
    if (condition != "") {
      query += " WHERE $condition";
    }
    if (limitCondition != "") {
      query += " " + limitCondition;
    }
    Map<String,dynamic >response = await dbHandler.fetchQueryRecords(
        query: query, fetchMode: fetchMode, formatColumns: getFieldFormats());
    if (response.getString("status").equalsIgnoreCase("success")) {
      result["status"] = "success";
      result["message"] = "record(s) fetched successfully";
      result["records"] = response["records"];
    } else {
      result["message"] = response["message"];
    }
  } catch (ex, stack) {
    result["message"] = Simplify.getExceptionMessage(ex, stack: stack);
  }
  return result;
}