map-reduce
Advanced tools
Comparing version 2.1.2 to 2.1.3
{ | ||
"name": "map-reduce", | ||
"description": "map-reduce on leveldb", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"homepage": "https://github.com/dominictarr/map-reduce", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -98,3 +98,2 @@ # Map Reduce for leveldb (via levelup) | ||
city: Oakland | New York | Berlin | Phnom Penh, etc... | ||
street: ..., | ||
type: taco | chili-dog | doner | noodles, etc... | ||
@@ -128,7 +127,3 @@ } | ||
db.mapReduce.add({ | ||
name : 'example', //defaults to 'default' | ||
start : '', //defaults to '' | ||
end : '~', //defaults to '~' | ||
//map-reduce uses ~ to prefix special data, | ||
//because ~ is the last ascii character. | ||
name : 'streetfood', | ||
map : function (key, value, emit) { | ||
@@ -141,3 +136,3 @@ //perform some mapping. | ||
emit( | ||
[obj.country, obj.state || '', obj.city, obj.street], | ||
[obj.country, obj.state || '', obj.city], | ||
//notice that we are just returning a string. | ||
@@ -173,7 +168,20 @@ JSON.stringify(obj.type) | ||
}) | ||
``` | ||
then query it like this: | ||
``` js | ||
//pass tail: false, because new streetfood doesn't appear that often... | ||
db.mapReduce.view('streetfood', {start: ['USA', 'CA'], tail: false}) | ||
.pipe(...) | ||
//or get the streetfood counts for each state. | ||
//we want to know about realtime changes this time. | ||
db.mapReduce.view('streetfood', {start: ['USA', true]}) | ||
``` | ||
## License | ||
MIT |
16170
184