CouchDB is not an SQL database engine. It's in the family of the "NoSQL" ones.
You don't do select, you don't create tables, etc.
It's completely different.
It's actually using a REST API to work. Like, to access all the documents, you access them using an HTTP GET on the following URL: http://some.server/someDbName/_all_docs
For a more thorough introduction, I suggest looking for "CouchDB tutorial" on Google.
You'll find good links like this one or this one. (I'm not vouching for any, they just look good as an introduction.)
To make an http request in node.js, you can use the request
method of the built-in http
module. A shortcut method is http.get
, which you can use like this:
var http = require( 'http' );
http.get( 'http://some.url/with/params', function( res ) {
// res has the values returned
});
Edit after reading your code:
Firstly, the doc you're using if outdated. Node is at v0.8, not 0.4.
Secondly, your request = require('request')
must give some problems (does the module exist?). I don't think the first part is even executed.
Thirdly, just try a GET request for now. Something like:
var http = require( 'http' );
http.get( 'http://localhost:5984/_all_dbs', function( res ) {
console.log( res );
});
See if it's working. If it is, you already know how to use couchdb ;)
Lastly, your request at the end doesn't seem wrong. Maybe it's related to require('request')
though, so I don't know.