December 2017
Intermediate to advanced
260 pages
7h 34m
English
To define a table you need to create an object with the required fields and extend the Table class and Exposed will create the table in the database for you with the fields as columns:
object Messages: Table() {
val id = integer("id").autoIncrement().primaryKey()
val name = varchar("name", 100)
}
It will result in the following query called by Exposed:
CREATE TABLE IF NOT EXISTS Messages (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL, CONSTRAINT pk_Messages PRIMARY KEY (id))
Read now
Unlock full access