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?

Était-ce utile?

La 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top