- Drop iterate methods without filtering
- Support for Template1-10
- Support for Query1-10
- Support for other operators: gt, lt, ge, le, mb, ne, nm, nn, nl, mt
- Support for boolean, date, timestamp, double, float, long, short, byte types
- Support for add, delete, remove, etc operations
This file contains hidden or 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
select (Cities.name, сount(Users.id)) from Cities join Users groupBy Cities.name forEach { | |
val (cityName, userCount) = it | |
if (userCount > 0) { | |
println("$userCount user(s) live(s) in $cityName") | |
} else { | |
println("Nobody lives in $cityName") | |
} | |
} |
This file contains hidden or 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
object Cities : Table() { | |
val id = id("id", autoIncrement = true) | |
val name = varchar("name", 50) | |
val all = id + name | |
} | |
select (Cities.all) forEach { | |
val (id, name) = it | |
println("$id: $name") |
This file contains hidden or 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
object Users : Table() { | |
val id = varchar("id", ColumnType.PRIMARY_KEY, length = 10) // PKColumn<String> | |
val name = varchar("name", length = 50) // Column<String> | |
val cityId = integer("city_id", ColumnType.NULLABLE, references = Cities.id) // Column<Int?> | |
val all = id + name + cityId // Column3<String, String, Int?> | |
} | |
object Cities : Table() { | |
val id = integer("id", ColumnType.PRIMARY_KEY, autoIncrement = true) // PKColumn<Int> |
This file contains hidden or 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
(Users.name + Users.cityId * Cities.name).filter { Users.id.equals("andrey") } forEach { | |
val (userName, cityName) = it | |
println("$userName lives in $cityName") | |
} |
This file contains hidden or 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
object Users : Table() { | |
val id = varchar("id", length = 10).id() // PKColumn<String, Users> | |
val name = varchar("name", length = 50) // Column<String, Users> | |
val requiredCityId = integer("required_city_id").references(Cities.id) // FKColumn<Int, Users> | |
val optionalCityId = integer("optional_city_id").references(Cities.id).optional() // FKOptionColumn<Int, Users> | |
val all = id + name + requiredCityId + optionalCityId // Template4<Users, String, Int, Int?> Select template | |
val values = id + name + requiredCityId + optionalCityId // Template4<Users, String, Int, Int?> Insert template | |
} |
This file contains hidden or 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
import kotlin.nosql.* | |
object Cities : Table() { | |
val id = integer("id").id().generated() // GeneratedPKColumn<Int, Cities> | |
val name = varchar("name", 50) // Column<String, Cities> | |
val all = id + name // Template2<Cities, Int, String> Select template | |
val values = name // Column<String, Cities> | |
} |
This file contains hidden or 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
import kotlin.nosql.* | |
import kotlin.nosql.dynamodb.* | |
object Users : Table() { | |
val id = string("id", length = 10).id() // PKColumn<String, Users> | |
val name = string("name", length = 50) // Column<String, Users> | |
val requiredCityId = integer("required_city_id") // Column<Int, Users> | |
val optionalCityId = integer("optional_city_id").nullable() // Column<Int?, Users> | |
val all = id + name + requiredCityId + optionalCityId // Template4<Users, String, Int, Int?> |
This file contains hidden or 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
// Get a document | |
Albums.find { details.artistId.equal(artistId) }.subscribe(onNext = { album -> | |
}, onError = { | |
}) | |
// Get selected fields of a document | |
Albums.find { id.equal(albumId) }.projection { sku + details.title + pricing }.subscribe(onNext = { | |
val (sku, title, pricing) = it | |
}, onError = { | |
}) |
This file contains hidden or 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
(dao.topics outerJoin dao.comments on { case (topic, comment) => comment.topicId === topic.id }).list | |
Results in | |
play.api.Application$$anon$1: Execution exception[[SlickException: Expected a collection type, found UnassignedType]] | |
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.7.jar:2.3.7] | |
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.7.jar:2.3.7] | |
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.7.jar:2.3.7] | |
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.7.jar:2.3.7] | |
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.5.jar:na] |
OlderNewer