exec method

Future exec()

Implementation

Future<dynamic> exec() async {
  if (table == null || entity == null) {
    throw Exception("table or entity parameter cannot be null");
  }

  // if (instance == null) {
  //   throw Exception("instance of object to assign cannot be null");
  // }
  var query =
      "SELECT ${_distinct ? "DISTINCT" : ""} ${_columns.join(",")} FROM $table";

  if (whereClause.length > 0) {
    query += " WHERE ${whereClause.join(" AND ")}";
  }
  if (_orders.length > 0) {
    query += " ORDER BY ${_orders.join(",")}";
  }
  if (_limit > 0) {
    query += " LIMIT $_limit";
  }
  await db.open();
  var results = await db.query(query);
  await db.close();
  if (results is List && _limit == 1) {
    return results[0];
  }

  return results;
}