groostav
02/10/2017, 10:36 PMwhere
function would take an AST representation of the body --effectively it takes source code, and then transcompiles the AST for it.name == "bob"
into WHERE c.name == bob
, of the equivalent mongo thing (iirc something resembling {"where" { eq { field { "fname" }, "bob" }}
aimozg
02/10/2017, 10:53 PMval q2 = Thing.TABLE.simpleQuery {
Thing::name eqAny listOf("thing1","thing2")
Thing::id eq 2
}
val result: Iterable<Model> = dbConnection.where { Model::fName eq "bob" }
looks nice enough.groostav
02/10/2017, 11:04 PMModel::fname
is trivially converted to a KProperty
is a really cool feature, but it doesn't go anywhere near far enough imho. When you get into queries of even minimal sophistication this is going to get ulgyaimozg
02/10/2017, 11:10 PMfun String.niceExtension(other:String, param:ParamEnum):Boolean
used in dbConnection.where { it.fName.niceExtension("bob", ParamEnum.ALPHA) }
?groostav
02/10/2017, 11:10 PMinline
are likely to be a boon to kotlin that C# doesnt haveaimozg
02/10/2017, 11:12 PMit.fName == "bob"
can be translated into WHERE fName = "bob"
, but an extension function will require fetching unfiltered resultsgroostav
02/10/2017, 11:13 PMit.extensionCall() && it.age > 25
it.age > 25
, using whatever seocndary indexes or other DB magic it has, then send that back to the driver (the library), to apply the rest of the filter, which includes a call do your extension methodsaimozg
02/10/2017, 11:15 PMgroostav
02/10/2017, 11:17 PMaimozg
02/10/2017, 11:17 PMdbConnection.where(Model::fName eq "bob").where { it.fName.extensionCall() }
groostav
02/10/2017, 11:17 PMaimozg
02/10/2017, 11:17 PMgroostav
02/10/2017, 11:17 PM