Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple DataSource extension for easy execution of query #139

Open
PatilShreyas opened this issue Nov 4, 2020 · 0 comments
Open

Simple DataSource extension for easy execution of query #139

PatilShreyas opened this issue Nov 4, 2020 · 0 comments

Comments

@PatilShreyas
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant