79

What modules are you using to connect to your CouchDB server, in your Node.js applications? And why would you recommend whatever module you are using?

cllpse
  • 21,396
  • 37
  • 131
  • 170

4 Answers4

71

When getting started, do not use CouchDB libraries in NodeJS!

There several, however they are largely thin layers wrapping the HTTP API. But Node has very strong HTTP support. It's no more trouble to make simple HTTP queries. It's simpler. It's less prone to errors. When CouchDB adds a feature, you won't need to wait for library support. You will learn and understand CouchDB better. It's well worth avoiding a library at first.

I use the built-in querystring module, and also Mikeal Rogers's request library, which is a super thin HTTP convenience library.

JasonSmith
  • 72,674
  • 22
  • 123
  • 149
  • 1
    Good advice. I've actually done a JavaScript wrapper for CouchDB, though :) – cllpse Apr 04 '11 at 09:07
  • thanks for "querystring" module suggestion. request is by far most robust and easy library to work with – Tomo Jul 03 '14 at 13:51
  • 1
    Yes, when getting started, the first thing I like to do is rewrite code that's already been written and tested. Wait, I don't like that. – Michael Cole Feb 16 '15 at 09:04
  • 2
    Sarcasm is not helpful. This answer is nearly four years old; although I still stand by it, because the point of the answer is that CouchDB is so simple, use a written, well-tested *HTTP* library, rather than a CouchDB one. But I also use and recommend Nano as well. It is a wonderful example of a lightweight library, with usefulness without getting in the way. – JasonSmith Feb 17 '15 at 06:39
  • That's right. You got it. – JasonSmith Mar 24 '15 at 05:50
  • @JasonSmith your answer teaches some of the worst programmer practices by assuming that code made by one person will be less prone to bugs than module used a lot by different people which source have been bugfixed over a long period of time. – Migol Oct 02 '15 at 23:38
50

Try to look at nano which offers simple and minimalistic API for CouchDB or high-level client cradle.

yojimbo87
  • 65,684
  • 25
  • 123
  • 131
  • While I'm here back on this question, I shared my anti-client opinion with Charlie Robbins from Nodejitsu. He understood, and he said Cradle had gained many features and was indeed worth the conceptual complexity overhead. – JasonSmith Jun 12 '11 at 01:24
  • 1
    Cradle has been mostly inactive for several months, with just maintenence updates from the nodejitu team. – dscape Jan 14 '12 at 16:32
  • 2
    @dscape: At the time of writing my answer it was the most popular and active module. You can edit it if you want and add your nano library first. – yojimbo87 Jan 14 '12 at 16:56
  • I didnt remove but added the edit. i think that makes more sense – dscape Feb 15 '12 at 21:13
45

I am the author of nano. When starting with CouchDB I did exactly as Jason Smith advised using Mikeals request library. Nano was born out of using that code in production and realizing I had some coded that could be improved and abstracted.

The end result is minimalistic and you still have a way to go down to the request level and do a request (which many users do).

Nano was really well accepted by the CouchBase team, mostly cause it's soo\ simple and maps well to the API.

If you are interested in checking out more check out this blog post: http://writings.nunojob.com/2011/08/nano-minimalistic-couchdb-client-for-nodejs.html

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
dscape
  • 2,506
  • 1
  • 22
  • 20
2

I've written a very clean and simple HTTP API wrapper, called node-couchdb-api. It doesn't add any bloat features like an ORM, and it follows typical Node.js conventions for callbacks and async code.

Dominic Barnes
  • 28,083
  • 8
  • 65
  • 90