Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes cradle.Connection.prototype.config #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/cradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ cradle.Connection.prototype.rawRequest = function (options, callback) {
Object.keys(this.options.headers).forEach(function (header) {
options.headers[header] = self.options.headers[header];
});


// Set property server function for handling them special at the response wrapper
options.serverFunction = (['/', '/_all_dbs', '/_config', '/_uuids', '/_stats', '/_active_tasks'].indexOf(options.path))? options.path : false;

if (options.query && Object.keys(options.query).length) {
for (var k in options.query) {
if (typeof(options.query[k]) === 'boolean') {
Expand Down Expand Up @@ -232,7 +235,7 @@ cradle.Connection.prototype.request = function (options, callback) {
return callback(new cradle.CouchError(body));
}

callback(null, self.options.raw ? body : new cradle.Response(body, res));
callback(null, self.options.raw ? body : new cradle.Response(body, res, options.serverFunction));
});
};

Expand Down
4 changes: 2 additions & 2 deletions lib/cradle/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// It allows us to call array-like methods on documents
// with a 'row' attribute.
//
this.Response = function Response(json, response) {
this.Response = function Response(json, response, serverFunction) {
var obj, headers;

// If there's an _id key, it's the result
Expand All @@ -29,7 +29,7 @@ this.Response = function Response(json, response) {
obj = json.results.slice(0);
obj.__proto__ = new(Array);
obj.last_seq = json.last_seq;
} else if (json.uuids) {
} else if (json.uuids && serverFunction === '/_uuids') {
obj = json.uuids;
obj.__proto__ = new(Array);
} else if (Array.isArray(json)) {
Expand Down