Skip to content

Commit

Permalink
Describe how to create design document
Browse files Browse the repository at this point in the history
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
avsej authored and trondn committed Feb 27, 2013
1 parent e7ee3a7 commit d551fa7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
31 changes: 29 additions & 2 deletions man/bsd/man3/lcb_make_http_request.3
Original file line number Diff line number Diff line change
Expand Up @@ -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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions man/man3couchbase/lcb_make_http_request.3couchbase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 29 additions & 2 deletions man/svr4/man3couchbase/lcb_make_http_request.3couchbase
Original file line number Diff line number Diff line change
Expand Up @@ -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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d551fa7

Please sign in to comment.