Frage

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?

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top