title: Retrieving all Documents from couchdb using Node.js
body: <p>I am writing a simple test app to experiment with the functionality of node.js and couchdb, so far i am loving it, but i ran in a snag. i have looked for and wide but can't seem to find an answer. My test server(a simple address book) does 2 things:</p>
  
  <ol>
  <li>if the user goes to <code>localhost:8000/{id}</code> then my app returns the name and address of the user with that id.<br/></li>
  <li>if the user goes to <code>localhost:8000/</code> then my app needs to return a list a names that are hyperlinks and takes them to the page <code>localhost:8000/{id}</code>.</li>
  </ol>
  
  <p>I was able to get the first requirement working. i cant not seem to find how to retrieve a list of all names from my couchdb. that is what i need help with. here is my code:</p>
  
  <pre><code>var http = require('http');
  var cradle = require('cradle');
  var conn = new(cradle.Connection)();
  var db = conn.database('users');
  
  function getUserByID(id) {
      var rv = "";
  
      db.get(id, function(err,doc) {
          rv = doc.name;
      rv += " lives at " + doc.Address;
  });
  
  return rv;
  }
  
  function GetAllUsers() {
  var rv = ""
  return rv;
  }
  
  var server =  http.createServer(function(req,res) {
  res.writeHead(200, {'Content-Type':'text/plain'});
  var rv = "" ;
  var id = req.url.substr(1);
  
      if (id != "")
      rv = getUserByID(id);
  else
      rv = GetAllUsers();
  
      res.end(rv);
  
  
  });
  
  server.listen(8000);
  console.log("server is runnig");
  </code></pre>
  
  <p>As you can see, I need to fill in the GetAllUsers() function. Any help would be appreciated. Thanks in advance.</p>