hmm.. I need to create a general DSL function, tha...
# getting-started
s
hmm.. I need to create a general DSL function, that I can use to fetch data from database and return the correct type of object... The problem is that I don't know how can I achieve that..
Copy code
public inline fun <reified T> Connection.testQuery(sqlString: String) : T? {
        
        try {
            val connection: Connection = sql2o.open()
            val results = connection.createQuery(sqlString).executeAndFetch(T::class)
            return results
        } catch (e: Exception) {
            println(e.toString())
            return null
        }
    }