Couchbase.Management.CouchbaseCluster.CreateDesignDocument C# (CSharp) Method

CreateDesignDocument() public method

public CreateDesignDocument ( string bucket, string name, string document ) : bool
bucket string
name string
document string
return bool
        public bool CreateDesignDocument(string bucket, string name, string document)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentException("Document name must be specified");

            JObject jObj;
            validateDesignDocument(document, out jObj);
            var uri = getDesignDocumentUri(bucket, name);

            var response = HttpHelper.Put(uri, _username, _password, document, HttpHelper.CONTENT_TYPE_JSON);

            var jsonResponse = JObject.Parse(response);
            return jsonResponse["ok"].Value<string>().Equals("true", StringComparison.CurrentCultureIgnoreCase);
        }

Same methods

CouchbaseCluster::CreateDesignDocument ( string bucket, string name, Stream source ) : bool

Usage Example

        public void SetUp()
        {
            _Client = CouchbaseClientFactory.CreateCouchbaseClient();

            //TODO: uncomment this line when next NuGet (1.2.7) is pushed
            //log4net.Config.XmlConfigurator.Configure();

            var cluster = new CouchbaseCluster("couchbase");

            var stream = File.Open(@"Data\\ThingViews.json", FileMode.Open);
            cluster.CreateDesignDocument("default", "things", stream);
        }