``` fun match(block: MatchBuilder.() -> Unit...
# dsl
t
Copy code
fun match(block: MatchBuilder.() -> Unit = {}) {
        val matchBuilder = MatchBuilder()
        matchBuilder.block()
        match = match.plus(matchBuilder.build())
    }
d
match = match.plus? What's match here? I think you mean
return matchBuilder.build()
?
What does the builder return? If Regex, just
infix fun Regex.with(toMatch: String) = toMatch.match(this)
@tjb
t
Ah sorry i should have added more code.
match
is an array of
Match
objects. I need to be able to have multiple
match
blocks in my DSL
Example:
Copy code
val m = builder {
        match {
            optional = true
            node {
                alias = "firstField"
                node = "Field"
                parameters = hashMapOf("id" to "12345", "hasTime" to false)
            }
        }

        match {
            node {
                alias = "secondField"
                node = "Field"
                parameters = hashMapOf("id" to "12345", "hasTime" to false)
            }
        }
    }
d
You initialize
m
once and re-use it?
t
no i do not
just once which is what i want
d
Like the initialization of a server?
And how do you run the match?
t
essentially this DSL is a query builder for neo4j. neo4j has a
WITH
clause and im struggling how to implement the
WITH
clause since its a separate method over
MATCH
.
my initial thought was to make
WITH
its own builder but it seems like that shouldnt be the right move.
ideally i want to do
Copy code
match {
            node {
                alias = "secondField"
                node = "Field"
                parameters = hashMapOf("id" to "12345", "hasTime" to false)
            }
        }
        
        with "hello, world, right, here"
but not sure how to implement the
with
here
d
You can get ideas of a db dsl here: https://github.com/orangy/squash
But I'm not sure if that's a bit heavy for your needs
t
ok cool i will take a look! yeah im just making a proof of concept right now
i appreciate the insight!
d
no problem