TableQuery

ldbc.statement.TableQuery
See theTableQuery companion object
trait TableQuery[A, O]

Trait for constructing SQL Statement from Table information.

Type parameters

A

The type of Table. in the case of Join, it is a Tuple of type Table.

O

The type of Optional Table. in the case of Join, it is a Tuple of type Optional Table.

Attributes

Companion
object
Source
TableQuery.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class On[A, B, AB, OO]

Members list

Type members

Types

type Entity = Extract[A]

Attributes

Source
TableQuery.scala

Value members

Abstract methods

def name: String

Name of Table

Name of Table

Attributes

Source
TableQuery.scala

Concrete methods

inline def ++=[P <: Product](values: List[P])(using check: P =:= Entity): Insert[A]

Method to construct a query to insert a table.

Method to construct a query to insert a table.

 TableQuery[City] ++= List(City(1L, "Tokyo"), City(2L, "Osaka"))

Type parameters

P

Scala types to be converted by Encoder

Value parameters

check

Check if the type of the value is the same as the Entity

values

Value to be inserted into the table

Attributes

Source
TableQuery.scala
inline def +=(value: Entity)(using mirror: Of[Entity]): Insert[A]

Method to construct a query to insert a table.

Method to construct a query to insert a table.

 TableQuery[City] += City(1L, "Tokyo")

Value parameters

mirror

Mirror of Entity

value

Value to be inserted into the table

Attributes

Source
TableQuery.scala
def delete: Delete[A]

Method to construct a query to delete a table.

Method to construct a query to delete a table.

 TableQuery[City]
   .delete

Attributes

Source
TableQuery.scala

Method to construct a query to drop a table.

Method to construct a query to drop a table.

 TableQuery[City]
   .dropTable

Attributes

Source
TableQuery.scala
inline def insert(using mirror: Of[Entity])(values: mirror.MirroredElemTypes*): Insert[A]

Method to construct a query to insert a table.

Method to construct a query to insert a table.

 TableQuery[City]
   .insert((1L, "Tokyo"))

Value parameters

mirror

Mirror of Entity

values

Value to be inserted into the table

Attributes

Source
TableQuery.scala
inline def insertInto[C](func: A => Column[C]): Into[A, C]

Method to construct a query to insert a table.

Method to construct a query to insert a table.

 TableQuery[City]
   .insertInto(city => city.id *: city.name)
   .values((1L, "Tokyo"))

If you want to use a join, consider using select as follows

  TableQuery[City]
    .insertInto(city => city.id *: city.name)
    .select(
      TableQuery[Country]
        .join(TableQuery[City])
        .on((country, city) => country.id === city.countryId)
        .select((country, city) => country.id *: city.name)
        .where((country, city) => city.population > 1000000)
    )

Type parameters

C

Scala types to be converted by Encoder

Value parameters

func

Function to construct an expression using the columns that Table has.

Attributes

Source
TableQuery.scala
def join[B, BO, AB, OO](other: TableQuery[B, BO])(using Aux[A, B, AB], Aux[O, BO, OO]): Join[A, B, AB, OO]

Method to construct a query to join a table.

Method to construct a query to join a table.

 TableQuery[City]
   .join(TableQuery[Country])
   .on((city, country) => city.countryId === country.id)

Attributes

Source
TableQuery.scala
def leftJoin[B, BO, OB, OO](other: TableQuery[B, BO])(using Aux[A, BO, OB], Aux[O, BO, OO]): Join[A, B, OB, OO]

Method to construct a query to left join a table.

Method to construct a query to left join a table.

 TableQuery[City]
   .leftJoin(TableQuery[Country])
   .on((city, country) => city.countryId === country.id)

Attributes

Source
TableQuery.scala
def rightJoin[B, BO, OB, OO](other: TableQuery[B, BO])(using Aux[O, B, OB], Aux[O, BO, OO]): Join[A, B, OB, OO]

Method to construct a query to right join a table.

Method to construct a query to right join a table.

 TableQuery[City]
   .rightJoin(TableQuery[Country])
   .on((city, country) => city.countryId === country.id)

Attributes

Source
TableQuery.scala
def select[C](func: A => Column[C]): Select[A, C]

Method to construct a query to select a table.

Method to construct a query to select a table.

 TableQuery[City]
   .select(city => city.id *: city.name)

Type parameters

C

Scala types to be converted by Decoder

Value parameters

func

Function to construct an expression using the columns that Table has.

Attributes

Source
TableQuery.scala

Method to construct a query to select all columns of a table.

Method to construct a query to select all columns of a table.

 TableQuery[City]
   .selectAll

Attributes

Source
TableQuery.scala

Method to construct a query to truncate a table.

Method to construct a query to truncate a table.

 TableQuery[City]
   .truncateTable

Attributes

Source
TableQuery.scala
inline def update[C](func: A => Column[C])(values: C): Update[A]

Method to construct a query to update a table.

Method to construct a query to update a table.

 TableQuery[City]
   .update(city => city.id *: city.name)((1L, "Tokyo"))

Type parameters

C

Scala types to be converted by Encoder

Value parameters

func

Function to construct an expression using the columns that Table has.

values

Value to be updated in the table

Attributes

Source
TableQuery.scala
inline def update[P <: Product](value: P)(using mirror: ProductOf[P], check: P =:= Entity): Update[A]

Method to construct a query to update a table.

Method to construct a query to update a table.

 TableQuery[City]
   .update(City(1L, "Tokyo"))

Type parameters

P

Scala types to be converted by Encoder

Value parameters

check

Check if the type of the value is the same as the Entity

mirror

Mirror of Entity

value

Value to be updated in the table

Attributes

Source
TableQuery.scala