-
Notifications
You must be signed in to change notification settings - Fork 24
Getting Started
And if you're in a hurry, you can include them in your build like this:
"com.rethinkscala" %% "core" % "0.4.6"
"com.rethinkscala" %% "core" % "0.4.7-SNAPSHOT"
Be sure to add the repository as well
"RethinkScala Repository" at "http://kclay.github.io/releases"
"RethinkScala Repository" at "http://kclay.github.io/snapshots"
#Imports
Rethinkscala has two query modes, Blocking
and Async
and provide the ability to switch between them at any time for whatever reason. Anywhere you would like to use rethinkscala be sure to include one of the following imports:
import com.rethinkscala.Blocking._
// or
import com.rethinkscala.Async._
This will include all helper function as well as all implicits to make writing rql a breeze.
Starting with 0.4.7-SNAPSHOT you can import an experimental feature which will provide a more functional way of working with query results (Try)
import com.rethinkscala.Blocking.functional._
case class CastBean(name:String,values:List[Int])
var table = r.tableAs[CastBean]("cast")
table.insert(CastBean("foo",List(1,2,3,4))).run
val values = table(0) \ "values"
var results:Try[Seq[Int]] = values.toSeq[Int].run
This will allow you to use for comprehension
If you are using rethinkdb 1.15+ you should use the json protocol, to set this up create a connection as so
val version = new Version3(host, port) // for not auth
val version = new Version3(host,port,authKey = "foobar") // for auth
You may also set the default database by passing db
or even set the max connections by passing maxConnections
(default = 5)