https://github.com/gr2m/couchdb-view-tester
Your friendly helper to quickly iterate on CouchDB views
https://github.com/gr2m/couchdb-view-tester
Last synced: 4 months ago
JSON representation
Your friendly helper to quickly iterate on CouchDB views
- Host: GitHub
- URL: https://github.com/gr2m/couchdb-view-tester
- Owner: gr2m
- Created: 2015-05-06T14:15:48.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-03-05T06:40:05.000Z (over 5 years ago)
- Last Synced: 2025-10-19T17:38:48.945Z (9 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 19
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# couchdb-view-tester
> Your friendly helper to quickly iterate on CouchDB views
## CLI usage
```
# npm install -g couchdb-view-tester
couchdb-view-tester [--watch] --map= --reduce=
```
### Example
Give your CouchDB database you want to test your map/reduce function on
is accessible at http://localhost:5984/mydb, do
```
couchdb-view-tester http://localhost:5984/mydb --map=./path/to/map.js --reduce=./path/to/reduce.js --limit=3
```
Both, `map.js` and `reduce.js` must return an anonymous function, for example
```js
// map.js
module.exports = function(doc) {
if (doc.Type == "customer") {
emit(doc._id, doc.LastName);
}
}
```
```js
// reduce.js
function (key, values, rereduce) {
return sum(values);
}
```
### View options
Options are equal to PouchDB's `db.query` options:
http://pouchdb.com/api.html#query_database
## Future plans / ideas
- add support for built in reduce functions
- add support for map functions only
- add docs for usage via `require('couchdb-view-tester')`
- add yours™