Question

So I've been scouring the documentation, but I couldn't find something as simple as this.

This statement seems to work

val row = MyTable.where(_.col1 === "val1").firstOption

But this one doesn't

val row = MyTable.where(_.col1 === "val1" && _.col2 === "val2").firstOption

How can I use multiple parameters in my where clause?

Was it helpful?

Solution

You can use underscore for one parameter only once. This is a shortcut for this:

val row = MyTable.where(x => x.col1 === "val1").firstOption

So in your case this should work:

val row = MyTable.where(value => value.col1 === "val1" && value.col2 === "val2").firstOption
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top