December 2017
Intermediate to advanced
260 pages
7h 34m
English
The following code snippet shows an example of how to do create, read, update, delete (CRUD) operations with Exposed:
transaction {
// Insert new message
Messages.insert { it[name] = "Hello Kotlin Developers!" } // Update an existing message Messages.update({Users.id eq 1}) { it[name] = "Hello Spring-Kotlin Developers" }
// Delete the messages table
drop(Messages)
}It results in the following queries:
INSERT INTO Messages (name) VALUES ('Hello Kotlin Developers!') UPDATE Messages SET name='Hello Spring-Kotlin Developers' WHERE Messages.id = 1 DROP TABLE Messages
Get all the users from the database:
for (message in Messages.selectAll()) { println("$message[Messages.name]}") }It will result in the following query: ...
Read now
Unlock full access