Comparing version 0.8.7 to 0.8.8
@@ -0,1 +1,6 @@ | ||
## version 0.8.8 | ||
- Added support for using entire buckets as the input for a map/reduce operation | ||
- Improved error handling | ||
## version 0.8.7 | ||
@@ -2,0 +7,0 @@ |
@@ -15,3 +15,5 @@ var restify = require('restify'); | ||
this.server.formatters['multipart/mixed'] =require('./lib/util/multipart'); | ||
this.server.formatters['application/json'] =require('./lib/util/json'); | ||
this.server.use(restify.acceptParser(this.server.acceptable)); | ||
this.server.use(restify.conditionalRequest()); | ||
@@ -18,0 +20,0 @@ this.server.use(restify.queryParser({ mapParams: false })); |
@@ -55,3 +55,3 @@ var RiakObject = require('./object'); | ||
result.push(this.objects[key]); | ||
}) | ||
}, this); | ||
@@ -58,0 +58,0 @@ return result; |
@@ -65,5 +65,3 @@ var Bucket = require('../bucket'); | ||
// Key filters | ||
if (!spec.bucket || !spec.key_filters) { | ||
if (!spec.bucket) { | ||
throw new restify.BadRequestError('Key filter inputs must have both a bucket and key_filter item'); | ||
@@ -75,9 +73,17 @@ } | ||
var result = []; | ||
var result; | ||
objects.forEach(function(object) { | ||
if (filterKey(object.key, spec.key_filters)) { | ||
result.push(new Input(object, null)); | ||
} | ||
}); | ||
if (spec.key_filters) { | ||
result = []; | ||
objects.forEach(function(object) { | ||
if (filterKey(object.key, spec.key_filters)) { | ||
result.push(new Input(object, null)); | ||
} | ||
}); | ||
} else { | ||
result = objects.map(function(object) { | ||
return new Input(object, null); | ||
}); | ||
} | ||
@@ -84,0 +90,0 @@ return result; |
@@ -44,7 +44,4 @@ var Bucket = require('../models/bucket'); | ||
// res.setHeader('content-type', 'multipart/mixed'); | ||
// res.send(result); | ||
} | ||
module.exports = links; |
@@ -59,2 +59,7 @@ var crypto = require('crypto'); | ||
function multipart(req, res, data) { | ||
if (data instanceof Error) { | ||
res.setHeader('Content-type', 'text/plain'); | ||
return data.message; | ||
} | ||
var mainBoundary = createBoundary(); | ||
@@ -61,0 +66,0 @@ |
{ | ||
"name": "mock-riak", | ||
"version": "0.8.7", | ||
"version": "0.8.8", | ||
"author": "Marco Tabini <marcot@tabini.ca>", | ||
@@ -5,0 +5,0 @@ "description": "A mock library that simulates a running Riak cluster (without actually having one)", |
@@ -10,11 +10,11 @@ var RiakClient = require('riak-js'); | ||
var payloads = [ { name : 'Marco' , email : 'marcot@tabini.ca' } , { name : 'Daniel' , email : 'daniel@example.org' } , { name : 'Andrea' , email : 'andrea@example.org' } ]; | ||
var bucket = 'things'; | ||
var bucket = 'things22'; | ||
async.each( | ||
payloads, | ||
function iterator(element, callback) { | ||
client.save(bucket, null, element, { index : { email_index : element.email } }, callback); | ||
}, | ||
function(err) { | ||
@@ -24,9 +24,8 @@ expect(err).to.be.null; | ||
client.mapreduce | ||
.add({ bucket : bucket , index : 'email_index_bin' , key : 'danielkkk@example.org' }) | ||
.add({ bucket : bucket }) | ||
.map('Riak.mapValuesJson') | ||
.run(function(err, result) { | ||
console.log(err); | ||
console.log(result); | ||
console.log(err, result); | ||
}); | ||
} | ||
); |
@@ -184,2 +184,38 @@ var Riak = require('../index'); | ||
it('should support entire buckets in input', function(done) { | ||
var payloads = [ { name : 'Marco' , email : 'marcot@tabini.ca' } , { name : 'Daniel' , email : 'daniel@example.org' } , { name : 'Andrea' , email : 'andrea@example.org' } ]; | ||
var bucket = 'things23'; | ||
async.each( | ||
payloads, | ||
function iterator(element, callback) { | ||
client.save(bucket, null, element, { index : { email_index : element.email } }, callback); | ||
}, | ||
function(err) { | ||
expect(err).to.be.null; | ||
client.mapreduce | ||
.add({ bucket : bucket }) | ||
.map('Riak.mapValuesJson') | ||
.run(function(err, result) { | ||
expect(err).to.be.null; | ||
expect(result).to.be.an('array'); | ||
expect(result).to.have.length(3); | ||
result.forEach(function(value, index) { | ||
expect(value).to.be.an('object'); | ||
expect(value).to.deep.equal(payloads[index]); | ||
}); | ||
done(); | ||
}); | ||
} | ||
); | ||
}); | ||
after(function (done) { | ||
@@ -186,0 +222,0 @@ server.stop(done); |
81807
31
1675