Jan 23, 2011

Grouch: A DSL For CouchDb

I put together a simple DSL for interacting with Groovy today. I'm calling it Grouch*. Using Grouch, using CouchDb is as easy as this:

import com.curiousattemptbunny.grouch.*

grouch = new Grouch('http://localhost:5984')
if (grouch.mydb.exists()) grouch.mydb.delete()
grouch.mydb.create()
grouch.mydb << [_id: 'mydoc', aField: 'aValue' ]
assert grouch.mydb.mydoc.aField == 'aValue'
* Thanks to Ben Acker for the name. Funnily enough someone else had the same idea for a name but never pushed any code.

No comments: