Go SDK How to Creating a design documents?


#1

couchbase version:4.0
GO SDK:1.0
couchbase number:one

JAVA SDK Creating design documents ,As follows:
CouchbaseCluster cluster = CouchbaseCluster.create(“127.0.0.1”);
Bucket bucket = cluster.openBucket(“mytest”);
// Get bucket manager
BucketManager bucketManager = bucket.bucketManager();

// Initialize design document
DesignDocument designDoc = DesignDocument.create(
“test”,
Arrays.asList(
DefaultView.create(“test”,
“function (doc, meta) { if (doc.timestamp >= 1448603514 && doc.timestamp <= 1448615436 ) {emit([doc.endpoint, doc.metric], [doc.value,doc.timestamp]);}}”))
)
);

// Insert design document into the bucket
bucketManager.insertDesignDocument(designDoc);

1.Go SDK No create function?Can initialize design document?example?
2.Map function “1448603514” and “1448615436” it can be a variable? example?

Many thanks for your help.


#2

Hey @lindan,

You can access the same BucketManager you see in the Java SDK by using the Manager() function of the Bucket class. You can take a look here for more information:

Cheers, Brett


#3

Thank you very much.