Hello, I'm new to Kotlin and Exposed, and I'm havi...
# exposed
n
Hello, I'm new to Kotlin and Exposed, and I'm having some difficulty with the DAO api. I'm trying to create a function that will have a where clause that is different depending on runtime user input. I don't appear to be able to use any if blocks inside the transaction block. I'm trying to do something like this:
Copy code
fun findX(xGt: BigDecimal?, xLt: BigDecimal?): List<DaoClass> {
    return transaction {
        DaoClass.find {
            var condition = TableClass.any()
            if (xGt != null) {
                condition = condition.and(TableClass.x.greater(xGt))
            }
            if (xLt != null) {
                condition = condition.and(TableClass.x.less(xGt))
            }

            condition
        }.toList()
    }
}
Is this possible?
t
You can replace
TableClass.any()
with
TableClass.id.isNotNull()