getOrderBy<TDef extends ITableDefinition> function

SqlRequest getOrderBy<TDef extends ITableDefinition>(
  1. OrderBy<ITableDefinition> orderBy(
    1. TDef e
    )?,
  2. TDef tableDefinition
)

Implementation

SqlRequest getOrderBy<TDef extends ITableDefinition>(OrderBy Function(TDef e)? orderBy, TDef tableDefinition) {
  late OrderBy orderByObj;

  if (orderBy == null) //
    return SqlRequest('', {});

  orderByObj = orderBy(tableDefinition);

  var sql = 'order by ' +
      orderByObj.columns //
          .map((e) => "${e.column.name} ${e.isAscending ? 'ASC' : 'DESC'}")
          .join(", ");

  return SqlRequest(sql, {});

}