couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <hknight...@gmail.com>
Subject CouchDB: Adding Map and Reduce Functions from command line using curl
Date Sun, 28 Jul 2013 23:15:52 GMT
I use the following from a Linux command line to create a database and
add documents:
curl -X PUT http://zurv3aqzm.iriscouch.com/xfruits
curl -X POST http://zurv3aqzm.iriscouch.com/xfruits -d
'{"_id":"1","user":"joe","xfruits":"peach","type":"pits"}' -H
"Content-Type: application/json"
curl -X POST http://zurv3aqzm.iriscouch.com/xfruits -d
'{"_id":"2","user":"joe","xfruits":"blueberry","type":"berries"}' -H
"Content-Type: application/json"
curl -X POST http://zurv3aqzm.iriscouch.com/xfruits -d
'{"_id":"3","user":"joe","xfruits":"strawberry","type":"berries"}' -H
"Content-Type: application/json"
curl -X POST http://zurv3aqzm.iriscouch.com/xfruits -d
'{"_id":"4","user":"joe","xfruits":"strawberry","type":"berries"}' -H
"Content-Type: application/json"

Here is my map function:
function(doc) {
  if (doc.fruits) emit(doc.fruits,doc.type.length);
}

Here is my reduce function:
_count

I know how to add the map function and reduce function using the admin
panel but how can I add these using only a command line with curl?

Mime
View raw message