Invokers
Invokers are the components of a Slick query that build up the SQL select statement. Slick exposes a variety of invokers that allow the construction of complex queries. Let's look at some of these invokers here:
The
map
invoker is useful to select individual columns or apply operations to columns:scala> db.withSession { implicit session => Tables.transactions.map { _.candidate }.take(5).list } List[String] = List(Obama, Barack, Paul, Ron, Paul, Ron, Paul, Ron, Obama, Barack)
The
filter
invoker is the equivalent of theWHERE
statements in SQL. Note that Slick fields must be compared using===
:scala> db.withSession { implicit session => Tables.transactions.filter { _.candidate === "Obama, Barack" }.take(5).list } List[Tables.Transactions#TableElementType] = List(Transaction(Some(1),Obama, Barack,Doe, John,TX,None,200,2010-06-22), ...
Similarly, to filter out donations to Barack Obama, use the
=!=
operator:scala> db.withSession { implicit...