Skip to content

Commit

Permalink
fix for #180 - allow use in query. Also support for max_results and c…
Browse files Browse the repository at this point in the history
…ontinuation params
  • Loading branch information
Alexander Popov committed Sep 4, 2013
1 parent c2acbb7 commit 18b419b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,21 @@ HttpClient.prototype.query = function(bucket, query, options, callback) {
value = value[0];
}

var type = typeof value == 'number' ? 'int' : 'bin',
key = "index/" + field + "_" + type + "/" + encodeURIComponent(value);
if ( field == "$bucket" ){
key = "index/" + field + "/" + encodeURIComponent(value);
}
else{
var type = typeof value == 'number' ? 'int' : 'bin',
key = "index/" + field + "_" + type + "/" + encodeURIComponent(value);
}

if (end) key += "/" + encodeURIComponent(end);

this.get(bucket, key, meta, function(err, data, _meta) {
var continuation = data.continuation;
data = data ? data.keys : undefined;
if ( continuation && data )
data.continuation = continuation;
meta.callback(err, data, _meta);
});

Expand Down
5 changes: 4 additions & 1 deletion lib/http-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ HttpMeta.queryProperties = [
'vtag',
'returnbody',
'chunked',
'buckets'
'buckets',
'max_results',
'return_terms',
'continuation',
]

module.exports = HttpMeta;
Expand Down
5 changes: 4 additions & 1 deletion lib/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ Meta.keywords = [
'operation',
'pool',
'_pool',
'agent'
'agent',
'continuation',
'max_results',
'return_terms'
]

module.exports = Meta;

0 comments on commit 18b419b

Please sign in to comment.