Created
February 20, 2018 06:24
-
-
Save oshai/b83de22a5d5da51aa76dc8793dd4c217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver") | |
transaction { | |
// insert new city. SQL: INSERT INTO Cities (name) VALUES ('St. Petersburg') | |
val stPeteId = Cities.insert { | |
it[name] = "St. Petersburg" | |
} get Cities.id | |
// 'select *' SQL: SELECT Cities.id, Cities.name FROM Cities | |
println("Cities: ${Cities.selectAll()}") | |
} | |
} | |
object Cities: IntIdTable() { | |
val name = varchar("name", 50) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment