0

假设我有这样的表格:

object Leagues : IntIdTable() {
   val name = varchar("name", 50).uniqueIndex()
}
object Matches: IntIdTable() {
   val game = reference("game", Games)
}
object Users: IntIdTable() {
   val name = varchar("name", 50).uniqueIndex()
}
object Bets: IntIdTable() {
   val match = reference("match", Matches)
   val user = reference("user", Users)
}

Daos 是:

class Bet(id: EntityID<Int>) : IntEntity(id) {
   companion object : IntEntityClass<Bet>(Bets)

   var match by Bets.match
   var user by Bets.user
}

我如何为 Bets 类编写 dao 或查询,以便我可以查询“给我玩家 X 在 Y 联赛中所做的所有赌注”。Bet.find { (user eq X) and (/* what here to get the leagues table ? */) }

4

1 回答 1

1
val bets = Bet.wrapRows(
    Bets.innerJoin(Matches).innerJoin(Leagues).select {
        Bets.user eq X.id and (Leagues.name eq "Y"  
    }
).toList()
于 2018-05-04T06:49:49.867 回答