CaoBase

abstract
class CaoBase[T, U, D <: Document[U]](bucket: ScalaBucket)(implicit evidence$1: ClassTag[D]) extends CaoTrait[T, String, U, D]

Base class for Couchbase Access Object. This class permit we interact (get/set/update/..) with couchbase server through a typed interface. Ex, given a class D <: Document (that means D is a subclass of com.couchbase.client.java.document.Document) instead of

 // com.couchbase.client.java.AsyncBucket#get
 get(id: String): Observable[D]
 // com.couchbase.client.java.AsyncBucket#upsert
 upsert(document: D): Observable[D]

, we can:

 get(id: String): Future[T]
 set(id: String, t: T): Future[D]

With T is your own type, ex case class User(name: String, age: Int)

To able to do that, we need implement this class' 2 abstract methods:

 def reads(u: U): T
 def writes(t: T): U
Type Params
D

the Document type

T

type that will be encoded before upsert using writes(t: T): U, and decoded after get using reads(u: U): T

U

the Document's content type, ex JsValue, primitive types,.. See classes that implement com.couchbase.client.java.document.Document for all available type (of course you can implement your own)

See also

WithCaoKey1

trait CaoTrait[T, String, U, D]
class Object
trait Matchable
class Any
class JsCao[T]
class JsCao2[T, A, B]
class StrCao[T]
class StrCao2[T, A, B]

Type members

Inherited types

final
type DocumentCAS = (T, Long)
Inherited from
CaoTrait

Value members

Concrete methods

final
def get(id: String): Future[T]
Value Params
id

document id

final
def getWithCAS(id: String): Future[DocumentCAS]
Value Params
id

document id

final
def remove(id: String): Future[D]
Value Params
id

document id

final
def set(id: String, t: T): Future[D]
Value Params
id

document id

t

the object of your own type T ex T=case class User(...) to be upsert into cb server

final
def update(id: String, t: T, cas: Long): Future[D]
Value Params
id

document id

t

the object of your own type T ex T=case class User(...) to be upsert into cb server

Inherited methods

final
def change(a: String)(f: Option[T] => T): Future[D]
Inherited from
CaoTrait
final
def changeBulk(aa: Seq[String])(f: Option[T] => T): Future[Seq[D]]
Inherited from
CaoTrait
protected
def createDoc(id: String, expiry: Int, content: U, cas: Long): D
Inherited from
CaoTrait
protected
def expiry(): Int
Inherited from
CaoTrait
final
def flatChange(a: String)(f: Option[T] => Future[T]): Future[D]
Inherited from
CaoTrait
final
def flatChangeBulk(aa: Seq[String])(f: Option[T] => Future[T]): Future[Seq[D]]
Inherited from
CaoTrait
final
def getBulk(aa: Seq[String]): Future[Seq[T]]
Inherited from
CaoTrait
final
def getBulkWithCAS(aa: Seq[String]): Future[Seq[DocumentCAS]]
Inherited from
CaoTrait
final
def getOrElse(a: String)(default: => T): Future[T]
Value Params
a

document id or the param of WithCaoKey1.key(a: A)

Inherited from
CaoTrait
final
def getOrElseWithCAS(a: String)(default: => T): Future[DocumentCAS]
Value Params
a

document id or the param of WithCaoKey1.key(a: A)

Inherited from
CaoTrait
final
def getOrUpdate(a: String)(default: => T): Future[T]
Value Params
a

document id or the param of WithCaoKey1.key(a: A)

Inherited from
CaoTrait
protected
def reads(u: U): T
Inherited from
CaoTrait
final
def setBulk(aa: Seq[String], tt: Seq[T]): Future[Seq[D]]
Inherited from
CaoTrait
final
def setT(a: String, t: T): Future[T]

convenient method. = set(..).map(_ => t)

convenient method. = set(..).map(_ => t)

Inherited from
CaoTrait
protected
def writes(t: T): U
Inherited from
CaoTrait