Reputation: 12101
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?
Upvotes: 3
Views: 812
Reputation: 23851
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
Upvotes: 6