dominicbarnes/node-couchdb-api — Issue #9: API v1.1.1 returns unparsed string instead of object when querying list function
Author: taris
Created: 2012-03-05 13:36:04+00:00
State: open

Hi!

I am querying a list function (http://dominicbarnes.us/node-couchdb-api/api/view/list.html) in my project and noticed that the behaviour changed from v1.0.0 to v1.1.1.
While the "response" in v1.0.0 returned an object, the "response" in v.1.1.1 contains the unparsed string.

```javascript
1.0.0: Value: [object Object] - Typeof: object
1.1.1: Value: {"total":19790} - Typeof: string
```

Use this ddoc for testing:

```javascript
{
"_id": "_design/list-test",
"language": "javascript",
"views": {
"view-func": {
"map": "function(oDocument)\n{\nemit(oDocument._id, 1)\n}"
}
},
"lists": {
"list-func": "function(oHead, oViewRequest)\n{\n var iTotalSum = 0;\n while (oCurrRow = getRow())\n {\n iTotalSum += oCurrRow.value;\n }\n\n send(toJSON({total: iTotalSum}));\n}"
}
}
```

and this script for executing with node:

```javascript
var couchdb = require("couchdb-api");

/** default values: "localhost", 5984 **/
var server = couchdb.srv("localhost", 5984);

var db = server.db("database");

db.ddoc("list-test").view("view-func").list("list-func", function (err, response) {
console.log("Value: "+response+" - Typeof: "+(typeof response));
});
```

Is this a bug or do i need to call it differently? The documentation says it should be an object (http://dominicbarnes.us/node-couchdb-api/api/callbacks.html)

Thx!