Home

Awesome

Build Status

Scala Rethinkdb Driver

Work in progress for RethinkDB 2.0 release.

FEATURES

Guide

TODO

SBT Users

val main = Project(....).settings(resolvers ++= Seq("RethinkScala Repository" at "http://kclay.github.io/releases"))

val rethinkscala = "com.rethinkscala" %% "core" % "0.5.0",
val rethinkscala = "com.rethinkscala" %% "core" % "0.5.1-SNAPSHOT"

To get started

import com.rethinkscala.Blocking._ // for blocking api
implicit val blockingConnection = Blocking(Version3)
import com.rethinkscala.Async._ // for async api
implicit val asyncConnection = Async(Version3)

Examples


scala> r.table("marvel").map(hero=> hero \ "combatPower" + hero \ "combatPower" * 2)
res2: com.rethinkscala.ast.RMap = RMap(Table(marvel,None,None),Predicate1(<function1>))


scala> import com.rethinkscala._
import com.rethinkscala._

scala> val version =new Version3("172.16.2.45")
version: com.rethinkscala.net.Version3 = Version3(172.16.2.45,28015,None,5)

scala> implicit val connection = new Connection(version)
connection: com.rethinkscala.Connection = Connection(Version2(172.16.2.45,28015,None,5))

scala> val info =DB("foo").table("bar").info
info: com.rethinkscala.ast.Info = Info(Table(bar,Some(false),Some(DB(foo))))

//case class DBResult(name: String, @JsonProperty("type") kind: String) extends Document
//case class TableInfoResult(name: String, @JsonProperty("type") kind: String, db: DBResult) extends Document

scala> val result = info.as[TableInfoResult]
result: Either[com.rethinkscala.net.RethinkError,com.rethinkscala.net.TableInfoResult] = Right(TableInfoResult(bar,TABLE,DBResult(test,DB)))

// selecting data
scala> r.db("test").table("foos").create.run
res1: Either[com.rethinkscala.net.RethinkError,Boolean] = Right(true)

scala> val table = r.db("test").table("foos")
table: com.rethinkscala.ast.Table = Table(foos,Some(false),Some(DB(test)))

scala> val records = for(i <-1 to  5) yield SelectFoo(i)
records: scala.collection.immutable.IndexedSeq[SelectFoo] = Vector(SelectFoo(1), SelectFoo(2), SelectFoo(3), SelectFoo(4), SelectFoo(5))

scala> table.insert(records).run
res2: Either[com.rethinkscala.net.RethinkError,com.rethinkscala.net.InsertResult] = Right(InsertResult(5,0,0,0,None,null,0,0))

scala> val results = table.between(2,4).order("id").as[SelectFoo]
results: Either[com.rethinkscala.net.RethinkError,Seq[SelectFoo]] = Right(Cursor(SelectFoo(2), SelectFoo(3), SelectFoo(4)))

scala> val results = table.filter(f=> f \ "id"> 2).as[SelectFoo]
results: Either[com.rethinkscala.net.RethinkError,Seq[SelectFoo]] = Right(Cursor(SelectFoo(3), SelectFoo(5), SelectFoo(4)))

scala> val results = table.filter(f=> f \ "id"> 2).order("id".desc).as[SelectFoo]
results: Either[com.rethinkscala.net.RethinkError,Seq[SelectFoo]] = Right(Cursor(SelectFoo(5), SelectFoo(4), SelectFoo(3)))


More found at here Be sure to check out the wiki

Installation

Note needs protobuf 2.5.0 installed


Checkout Main repo
sudo apt-get install protobuf-compiler
git clone git@github.com:kclay/rethink-scala.git
cd rethink-scala
sbt compile

Version

###0.4.9 - 12/07/15

###0.4.6 - 05/12/15

###0.4.5 - 10/12/14

###0.4.4 - 8/26/214

###0.4.3 - 9/24/13

###0.4.2 - 08/12/13

###0.4 - 08/09/13

###0.3 - 07/28/13

###0.2 - 07/04/13

Streams are now supported, this means that when using methods like .getAll and between the results will be wrapped in a com.rethinkscala.net.Cursor[R] which will act like an Seq[R]

###0.1 - Initial release