order method

DBHelper order({
  1. String? column = "created_at",
  2. DatabaseOredrs? order = DatabaseOredrs.asc,
})

Implementation

DBHelper order(
    {String? column = "created_at",
    DatabaseOredrs? order = DatabaseOredrs.asc}) {
  String q = "  ORDER BY  $column  ${order?.getUpperString} ";
  if (_query.contains("SELECT")) {
    if (!_query.contains("LIMIT")) {
      if (!_query.contains("ORDER")) {
        _query += q;
      }
    } else {
      List splitedQuery = _query.split("LIMIT");
      splitedQuery[0] += "$q LIMIT ";

      _query = splitedQuery.join();
    }
  } else {
    _query += "SELECT * FROM $table  $q ";
  }

  return this;
}