CouchDB example, starting points?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

CouchDB example, starting points?


Thanks for the nice framework.

I'm a Scala newbie, and attempting to use dispatch.couch.

I couldn't find any examples for binding/extracting Couch responses to pojos using the dispatch.Doc and dispatch.Id classes.

By looking through the codeusing the liftweb json parser, I got the following to work for me:

import dispatch._
import dispatch.couch._
import net.liftweb.json.DefaultFormats
import net.liftweb.json.JsonParser._

val http = new Http
val db = Db(Couch(), "example")

val text = http(db / "02a678af5d7408bf812fecc5d1d693ae" as_str)

implicit val formats = new DefaultFormats
val json = parse(text)
var pojo = json.extract[MyPojo] // MyPojo is a simple case class

This works okay, but wondering how I could do the equivalent using Doc and Id without using the liftweb parser?


Reply | Threaded
Open this post in threaded view

Re: CouchDB example, starting points?

Hi, there are some examples of getting data out documents using dispatch.couch in the tests:

Also, this small document server that I use for the Dispatch web site uses that interface:;a=blob;f=src/main/scala/sling/Press.scala;h=a1643080ebf8f3bb31bf6f88be63c615b5431d91;hb=HEAD

But, I'm not sure that dispatch.couch would be suitable for a larger project without more development. Other people have developed interfaces to couch using Dispatch that are further along, one using dispatch-json:

And another using dispatch-lift-json: