# Quick CouchDB Fun

I'm a fan of the command line, so when I found out I could just use curl to mess with CouchDB instead of Futon I was happy. If you want to create a new document with views under some database, you can do this:

curl -d @t.json -u un:pw -H "Content-Type: application/json" -X PUT http://dynamobi.cloudant.com/sw/_design/rar

This will take the contents of the file t.json (which is below) and send them off to CouchDB. It will create a new document called "rar" under the "sw" database. Here is t.json:

{
"views": {
"shipped4": {
"map": "function(doc) { if ( doc.order_line_item[15].PRODUCTNAME == '1936 Chrysler Airflow') emit(doc._id, {ProductName: doc.order_line_item[15].PRODUCTNAME} ); }"
}
}
}