orangy
val personByIdQuery = query(PersonTable).where { PersonTable.id eq id }
then we bind the query to types
val personModel = personByIdQuery.bindTo<Person> {
bind(Person::place, placeQuery)
bindMany(Person::contacts, contactsQuery)
}
and types involved being simple interfaces like
interface Person {
val id: Long
val login: String
val firstName: String
val lastName: String
val contacts: Iterable<Contact>
val place: Place
}
and then finally executing a model in a transaction:
val person = db.transaction { personModel.execute() }
which gives us instance of type Person