API to create view
Thu, 04/05/2012 - 00:10
Hi,
Is there any java API or any other means to create a view other than doing it manually via console ?
Thanks & Regards,
Divya
Thu, 12/20/2012 - 10:14
I've been looking for this too, looks like a good option is to use the rest interface:
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-desig...
- Creating Views ------
Divya,
I am a newbie to couchbase but found that the view is simply a document with a special _id and format. So I simply format it correctly and then use the save document command in my API of choice. Here is a sample view:
{
"_id": "_design/application",
"_rev": "1-C1687D17",
"views": {
"viewname": {
"map": "function(doc) { ... }",
"reduce": "function(keys, values) { ... }"
}
}
}
Here is a link that I have found quite helpful though it was written for CouchDB - http://guide.couchdb.org/editions/1/en/cookbook.html
Thanks.
Mark