From 18b419bd084970673f281cf9c3f224f30baa5047 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 4 Sep 2013 18:03:34 +0400 Subject: [PATCH] fix for https://github.com/mostlyserious/riak-js/issues/180 - allow use in query. Also support for max_results and continuation params --- lib/http-client.js | 12 ++++++++++-- lib/http-meta.js | 5 ++++- lib/meta.js | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/http-client.js b/lib/http-client.js index a7c6fa5..66db4a1 100644 --- a/lib/http-client.js +++ b/lib/http-client.js @@ -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); }); diff --git a/lib/http-meta.js b/lib/http-meta.js index e80d10c..5be748f 100644 --- a/lib/http-meta.js +++ b/lib/http-meta.js @@ -222,7 +222,10 @@ HttpMeta.queryProperties = [ 'vtag', 'returnbody', 'chunked', - 'buckets' + 'buckets', + 'max_results', + 'return_terms', + 'continuation', ] module.exports = HttpMeta; diff --git a/lib/meta.js b/lib/meta.js index d8ef892..974fc22 100644 --- a/lib/meta.js +++ b/lib/meta.js @@ -216,7 +216,10 @@ Meta.keywords = [ 'operation', 'pool', '_pool', - 'agent' + 'agent', + 'continuation', + 'max_results', + 'return_terms' ] module.exports = Meta;