From the previous couchbase related questions, do you seem to be using the java SDK? Both 1.4 and 2.0 lines of the SDK allow you to programmatically create design documents and presentations.
With Java SDK 1.4.x
You need to load the view definitions (map functions, reduce the functions in which the project document should be executed), as lines. See the documentation at http://docs.couchbase.com/couchbase-sdk-java-1.4/#design-documents .
Basically you create a ViewDesign
in a DesignDocument
, which you insert into the database via CouchbaseClient
:
DesignDocument designDoc = new DesignDocument("beers"); designDoc.setView(new ViewDesign("by_name", "function (doc, meta) {" + " if (doc.type == \"beer\" && doc.name) {" + " emit(doc.name, null);" + " }" + "}")); client.createDesignDoc(designDoc);
With Java SDK 2.0.x
In the same way, you should load definitions of your kind (map functions, shorten the functions in which the project document should be executed), as lines.
Then you deal with DesignDocument
by adding a DesignDocument
to it and inserting the design document into the bucket through the Bucket
BucketManager
:
List<View> viewsForCurrentDesignDocument = new ArrayList<View>(viewCountForCurrentDesignDoc);
source share