Regarding the polishing I noted these things:

>> - Uses exceptions more than Boxes, in one case it even open_!'s a  
>> Box to generate an exception. Though, this does fit better into the  
>> Dispatch style, and I find in practice it works okay because I tend  
>> to be wrapping http(database...) in tryo anyway, since dispatch  
>> reports non-success status codes as exceptions.

I don't know that I intend to fix this until I see a better path.  
There are a couple places where this is an issue:
- When Couch responds with something we plain don't understand.  
Dispatch will report an exception here if Couch responds with non-2xx,  
so I think it might be reasonable to cause an exception in this case,  
to follow the use case of Dispatch. I'd be glad to hear thoughts on  
this.
- When the code really needs a JObject, but is passed a JValue (this  
is the toJObject thing mentioned later). I originally had it passing  
JObject around, but I found it got in the way. If people feel strongly  
about this I can look about switching it back and trying to figure out  
ways to make it clean, but I don't personally think it's that bad.  
Again, comments?

>> - Multi-document fetch is not implemented. It should be doable via  
>> ComplexQueryParam (which is currently not populated)

I'll implement this before submitting.

>> - Some of the query parameters are not unit tested.

I'll try to get to implementing this before submitting.

>> - toJObject is my (not so) secret shame.

As above

>> - no examples (but the test suite could probably be useful to teach  
>> in the interim)

I'm awful at examples and non-auto documentation. Do people think a  
README/wiki and unit tests are sufficient?

>> - no vscaladocs are generated by the POM I have, haven't yet  
>> figured out the maven magic to get that going

I'll fix this, though it'll be fixed when integrated to lift by using  
lift's maven infrastructure.

Any additional issues that need polishing, I'd love to hear about.

-Ross

On Jan 4, 2010, at 2:34 AM, Marius wrote:

> Since CouchDB is Apache 2.0 licence I think this project should make
> it into /lift-persistence after some more polishing (like the ones you
> mentioned). I think it would be a very cool addition to lift.
>
> Br's,
> Marius
>
> On Jan 4, 8:56 am, Ross Mellgren <dri...@gmail.com> wrote:
>> Hi all,
>>
>> I've written a small library (http://github.com/Dridus/couchlift)  
>> that provides an integration to CouchDB using Lift JSON and  
>> Dispatch. Dispatch has an existing binding to Couch, but it uses  
>> its own JSON, and it's a bit thin.
>>
>> It's fairly uncomplicated -- it deals in JValues directly rather  
>> than some more "object database" like approach (perhaps baking in  
>> use of Lift JSON's excellent extraction capabilities), since that's  
>> the most general and it's pretty easy to just add extract/decompose  
>> calls as desired. I also opted against building any kind of design  
>> DSL because it felt like too much structure.
>>
>> Here's some example code of use (adapted from the test suite):
>>
>> val http = new Http
>> val database = new Database("my_database") // assumes localhost:5984
>>
>> val design: JObject =
>>     ("language" -> "javascript") ~
>>     ("views" -> (("all_students" -> ("map" -> "function(doc) { if  
>> (doc.type == 'student') { emit(null, doc); } }")) ~
>>                  ("students_by_age" -> ("map" -> "function(doc)  
>> { if (doc.type == 'student') { emit(doc.age, doc); } }")) ~
>>                  ("students_by_age_and_name" -> ("map" -> "function 
>> (doc) { if (doc.type == 'student') { emit([doc.age, doc.name],  
>> doc); } }"))))
>>
>> val docs: List[JObject] =
>>     (("type" -> "student") ~ ("name" -> "Alice")   ~ ("age" ->  
>> 10)) ::
>>     (("type" -> "student") ~ ("name" -> "Bob")     ~ ("age" ->  
>> 11)) ::
>>     (("type" -> "student") ~ ("name" -> "Charlie") ~ ("age" ->  
>> 11)) ::
>>     ...
>>     Nil
>>
>> http(database create)
>> docs foreach { doc => http(database store doc) } // store figures  
>> out whether it's PUT or POST and where by looking at the doc
>> http(database.design("my_design") <<<# design) // <<<# is direct PUT
>> http(database query("my_design", "all_students", Query.limit(2)))
>> http(database query("my_design", "students_by_age", Query.from(11),  
>> Query.to(12)))
>>
>> It's young, and I've only used it for a small personal project, so  
>> I'm sure there's improvements that could be made.
>>
>> There are a couple of specific issues/warts that I know about:
>>
>> - Uses exceptions more than Boxes, in one case it even open_!'s a  
>> Box to generate an exception. Though, this does fit better into the  
>> Dispatch style, and I find in practice it works okay because I tend  
>> to be wrapping http(database...) in tryo anyway, since dispatch  
>> reports non-success status codes as exceptions.
>> - Multi-document fetch is not implemented. It should be doable via  
>> ComplexQueryParam (which is currently not populated)
>> - Some of the query parameters are not unit tested.
>> - toJObject is my (not so) secret shame.
>> - no examples (but the test suite could probably be useful to teach  
>> in the interim)
>> - no vscaladocs are generated by the POM I have, haven't yet  
>> figured out the maven magic to get that going
>>
>> I've already posted it to github, so I suppose anyone could use it  
>> if they want, however I'd be glad to contribute it to Lift, if you  
>> folks think that it's useful to have, up to par, and should be  
>> included. I don't know if the dependency on Dispatch is kosher, so  
>> perhaps that's a reason not to.
>>
>> Thoughts? Comments on the library independent of the Lift context?
>>
>> -Ross
>>
>> P.S. I'm happy to post this to the general list as well, but I  
>> wanted to run it by you guys first.
>
> --
>
> You received this message because you are subscribed to the Google  
> Groups "Lift-committers" group.
> To post to this group, send email to lift-committ...@googlegroups.com.
> To unsubscribe from this group, send email to 
> lift-committers+unsubscr...@googlegroups.com 
> .
> For more options, visit this group at 
> http://groups.google.com/group/lift-committers?hl=en 
> .
>
>

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to