All Downloads are FREE. Search and download functionalities are using the official Maven repository.

doobieroll.snippets.CommonSnippets.scala Maven / Gradle / Ivy

The newest version!
package doobieroll.snippets
import doobie.util.fragment.Fragment
import doobieroll.TableColumns
import cats.syntax.all._

trait CommonSnippets {
  def selectColumnsFrom(tableColumns: TableColumns[_]): Fragment =
    Fragment.const(
      s"SELECT ${tableColumns.listStr} FROM ${tableColumns.tableNameStr}",
    )

  def selectColumns(
    firstColumns: Fragment,
    otherColumns: Fragment*,
  ): Fragment =
    (firstColumns +: otherColumns).toList.foldSmash(
      Fragment.const("SELECT"),
      Fragment.const0(","),
      Fragment.empty,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy