toff63 / lovecouch

A CouchDB Library for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lovecouch

An asynchronous CouchDB Library for Scala

Still very in a very volatile state.

The goal is to implement all relevant API from the CouchDB API Reference

Current dependencies are the Plat 2 Json Library for Json Parsing, Spray for Http Client as well as Akka

All methods will return a Future[U] where U is whatever object is wanted whenever everything is done.

If an error occurs, than a CouchDBException will be thrown

Everything is in the com.bryanjos.lovecouch package

import com.bryanjos.lovecouch._
import akka.actor.ActorSystem

implicit val system = ActorSystem()
implicit val context = system.dispatcher

val couchDB = CouchDB() //Uses default host and port
val database = Database("test", couchDB.url)

case class Guy(_id: Option[String] = None, _rev: Option[String] = None, name: String, age: Long) //Make sure _id and _rev are defined
implicit val guyFmt = Json.format[Guy] //Json formatter

val guy = Guy(name = "Alf", age = 23)
database.createDocument[Guy](guy) map {
result =>
    //A DocumentResult is returned
}

About

A CouchDB Library for Scala

License:MIT License