2

Since CouchDB has very few API documentation (at least I can not find it), I would like to inspect some JavaScript objecs myself. What is the best way to do this?

For example, show functions recive the request object req as argument. How to find out, which properties (cookies, requested url,...) this request object precisely has?

Witek
  • 6,160
  • 7
  • 43
  • 63

5 Answers5

5

For your specific question - how to write _show functions - see the relevant documentation in the CouchDB Wiki: Formatting with Show and List. That document then cross-references to the External Processes documentation for details on the request object. In general, the wiki is a treasure trove of information - most of the API documentation is there. It can just take some looking.

You can also experiment directly with JavaScript, as indicated by Nathan. You could write a show function that just stringifies the parameters (with JSON.stringify()) and displays them so you can see what they actually are.

Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93
1

Have a look at the CouchOne Docs and the open CouchDB Book.

b_erb
  • 20,932
  • 8
  • 55
  • 64
1

You can write code to inspect what properties an object has, see Iterating over every property of an object in javascript using Prototype?

Community
  • 1
  • 1
Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
1

I'm not happy with the couchdb documentation either.

In the CouchDB Guide there is some information about the req object that is passed to the list function: http://guide.couchdb.org/editions/1/en/transforming.html

I guess it will look quite the same in show functions.

But you should also be able to use toJSON(req) in order to get its content.

tautologe
  • 1,781
  • 2
  • 15
  • 14
0

To answer your original question, I often find myself writing a quick show/list function something like this example to quickly jog my memory about request (or other) options:

function (doc, req) {
    provides("text", function () {
        return JSON.stringify(req, null, 4);
    });
}
natevw
  • 16,807
  • 8
  • 66
  • 90