Permalink
Browse files

Describe how to create design document

In reply to http://www.couchbase.com/forums/thread/create-view-c-api

Change-Id: I05e6c1b6e5df64c2820e176d60b40edd85296d3d
Reviewed-on: http://review.couchbase.org/24892
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
1 parent e7ee3a7 commit d551fa70196793ce564d9e9a02c6e0bcc5979b41 @avsej avsej committed with trondn Feb 27, 2013
View
31 man/bsd/man3/lcb_make_http_request.3
@@ -2,12 +2,12 @@
.\" Title: lcb_make_http_request
.\" Author: Trond Norbye <trond.norbye@couchbase.com>
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 01/07/2013
+.\" Date: 02/27/2013
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "LCB_MAKE_HTTP_REQUES" "3" "01/07/2013" "\ \&" "\ \&"
+.TH "LCB_MAKE_HTTP_REQUES" "3" "02/27/2013" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -200,6 +200,33 @@ if (err != LCB_SUCCESS) {
.if n \{\
.RE
.\}
+.sp
+Example 4: Save design document \(oq_design/test\(cq with trivial \(oqall\(cq view
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+const char *docid = "_design/test";
+const char *doc = "{\e"views\e":{\e"all\e":{\e"map\e":\e"function (doc, meta) { emit(meta\&.id, null); }\e"}}}";
+lcb_http_cmd_t cmd;
+lcb_http_request_t req;
+cmd\&.version = 0;
+cmd\&.v\&.v0\&.path = docid;
+cmd\&.v\&.v0\&.npath = strlen(docid);
+cmd\&.v\&.v0\&.body = doc;
+cmd\&.v\&.v0\&.nbody = strlen(doc);
+cmd\&.v\&.v0\&.method = LCB_HTTP_METHOD_PUT;
+cmd\&.v\&.v0\&.content_type = "application/json";
+lcb_error_t err = lcb_make_http_request(instance, NULL,
+ LCB_HTTP_TYPE_VIEW,
+ &cmd, &req);
+if (err != LCB_SUCCESS) {
+ \&.\&.\&. failed to schedule request \&.\&.\&.
+.fi
+.if n \{\
+.RE
+.\}
.SH "ATTRIBUTES"
.sp
See lcb_attributes(5) for descriptions of the following attributes:
View
19 man/man3couchbase/lcb_make_http_request.3couchbase.txt
@@ -143,6 +143,25 @@ Example 3: Delete bucket via REST management API
if (err != LCB_SUCCESS) {
... failed to schedule request ...
+Example 4: Save design document `_design/test' with trivial `all' view
+
+ const char *docid = "_design/test";
+ const char *doc = "{\"views\":{\"all\":{\"map\":\"function (doc, meta) { emit(meta.id, null); }\"}}}";
+ lcb_http_cmd_t cmd;
+ lcb_http_request_t req;
+ cmd.version = 0;
+ cmd.v.v0.path = docid;
+ cmd.v.v0.npath = strlen(docid);
+ cmd.v.v0.body = doc;
+ cmd.v.v0.nbody = strlen(doc);
+ cmd.v.v0.method = LCB_HTTP_METHOD_PUT;
+ cmd.v.v0.content_type = "application/json";
+ lcb_error_t err = lcb_make_http_request(instance, NULL,
+ LCB_HTTP_TYPE_VIEW,
+ &cmd, &req);
+ if (err != LCB_SUCCESS) {
+ ... failed to schedule request ...
+
ATTRIBUTES
----------
See lcb_attributes(5) for descriptions of the following attributes:
View
31 man/svr4/man3couchbase/lcb_make_http_request.3couchbase
@@ -2,12 +2,12 @@
.\" Title: lcb_make_http_request
.\" Author: Trond Norbye <trond.norbye@couchbase.com>
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 01/07/2013
+.\" Date: 02/27/2013
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "LCB_MAKE_HTTP_REQUES" "3couchbase" "01/07/2013" "\ \&" "\ \&"
+.TH "LCB_MAKE_HTTP_REQUES" "3couchbase" "02/27/2013" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -200,6 +200,33 @@ if (err != LCB_SUCCESS) {
.if n \{\
.RE
.\}
+.sp
+Example 4: Save design document \(oq_design/test\(cq with trivial \(oqall\(cq view
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+const char *docid = "_design/test";
+const char *doc = "{\e"views\e":{\e"all\e":{\e"map\e":\e"function (doc, meta) { emit(meta\&.id, null); }\e"}}}";
+lcb_http_cmd_t cmd;
+lcb_http_request_t req;
+cmd\&.version = 0;
+cmd\&.v\&.v0\&.path = docid;
+cmd\&.v\&.v0\&.npath = strlen(docid);
+cmd\&.v\&.v0\&.body = doc;
+cmd\&.v\&.v0\&.nbody = strlen(doc);
+cmd\&.v\&.v0\&.method = LCB_HTTP_METHOD_PUT;
+cmd\&.v\&.v0\&.content_type = "application/json";
+lcb_error_t err = lcb_make_http_request(instance, NULL,
+ LCB_HTTP_TYPE_VIEW,
+ &cmd, &req);
+if (err != LCB_SUCCESS) {
+ \&.\&.\&. failed to schedule request \&.\&.\&.
+.fi
+.if n \{\
+.RE
+.\}
.SH "ATTRIBUTES"
.sp
See lcb_attributes(5) for descriptions of the following attributes:

0 comments on commit d551fa7

Please sign in to comment.