Skip to content

Simple DataSource extension for easy execution of query #139

Description

@PatilShreyas

Currently what I need to do is

    dataSource.connection.use { connection ->
        NormQuery().query(
            connection,
            NormParams(param1=value1, param2=value2, paramN=valueN)
        )
    }

So here basically I manually need to use connection and NormParams for passing parameters to the query.


If we declare method like

    fun <P, R : Any> DataSource.runQuery(query: Query<P, R>, params: P.() -> Unit): R {
         val result = ... // Get result data class
         return result
    }

Then we can use Norm generated classes like...

    fun addSomething() {
        val result = dataSource.runQuery(NormQuery()) {
            param1 = value1
            param2 = value2
            paramN = valueN
        }
    }

Here param and response result will be generic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions