getSelect<TDef extends ITableDefinition> function

SqlRequest getSelect<TDef extends ITableDefinition>(
  1. TDef tableDefinition, [
  2. Column col1(
    1. TDef e
    )?,
  3. Column col2(
    1. TDef e
    )?,
  4. Column col3(
    1. TDef e
    )?,
  5. Column col4(
    1. TDef e
    )?,
])

Implementation

SqlRequest getSelect<TDef extends ITableDefinition>(
  TDef tableDefinition, [
  Column Function(TDef e)? col1,
  Column Function(TDef e)? col2,
  Column Function(TDef e)? col3,
  Column Function(TDef e)? col4,
]) {
  if (col1 == null) //
    return SqlRequest("select * ", {});

  var columnListSql = [
    col1.call((tableDefinition)).name,
    col2?.call((tableDefinition)).name,
    col3?.call((tableDefinition)).name,
    col4?.call((tableDefinition)).name,
  ].where((x) => x != null).join(", ");

  return SqlRequest("select $columnListSql", {});
}