Skip to content

Instantly share code, notes, and snippets.

@oshai
Created February 20, 2018 06:24
Show Gist options
  • Save oshai/b83de22a5d5da51aa76dc8793dd4c217 to your computer and use it in GitHub Desktop.
Save oshai/b83de22a5d5da51aa76dc8793dd4c217 to your computer and use it in GitHub Desktop.
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