Beispiel #1
0
        private static async void DemoCreateUserIndexes()
        {
            var bucketName       = new CouchbaseConfiguration().GetBucket();
            var createIndexQuery = new QueryRequest().Statement("CREATE PRIMARY INDEX ON `workshop`");

            var result = await bucket.QueryAsync <dynamic>(createIndexQuery);

            if (result.Success)
            {
                Console.WriteLine("CREATE PRIMARY INDEX ON `workshop` succeeded");
            }
            else
            {
                Console.WriteLine("CREATE PRIMARY INDEX ON `workshop` failed");
            }

            var createIndex = new QueryRequest().Statement("CREATE INDEX `by_type_ix` ON `workshop`(type)");

            var result2 = await bucket.QueryAsync <dynamic>(createIndex);

            if (result2.Success)
            {
                Console.WriteLine("CREATE INDEX ON `workshop`(type) succeeded");
            }
            else
            {
                Console.WriteLine("CREATE INDEX ON `workshop`(type) failed");
            }
        }
Beispiel #2
0
        private static void CreateCluster()
        {
            var cbConfig = new CouchbaseConfiguration();
            var port     = cbConfig.GetPort();

            var hosts  = cbConfig.GetHosts().Select(x => new Uri(string.Format("{0}:{1}/pools", x, port))).ToList();
            var config = new ClientConfiguration()
            {
                Servers = hosts,
            };

            ClusterHelper.Initialize(config);

            cluster = ClusterHelper.Get(); // Single connection, do not use using (do not dispose a recreate)

            //var cm = cluster.CreateManager("Administrator", "123456");
        }
Beispiel #3
0
        public static void CreateBucketConnection()
        {
            var cluster  = ClusterFactory.GetCluster();
            var cbConfig = new CouchbaseConfiguration();

            var password = cbConfig.GetPassword();

            if (!string.IsNullOrWhiteSpace(password))
            {
                bucket = cluster.OpenBucket(cbConfig.GetBucket(), password);
            }
            else
            {
                bucket = cluster.OpenBucket(cbConfig.GetBucket());
            }

            bucketManager = bucket.CreateManager("Administrator", "123456");
        }
 private static void CreateCluster()
 {
     var cbConfig = new CouchbaseConfiguration();
     ///
 }
Beispiel #5
0
 public CouchbaseConnection(IOptions <CouchbaseConfiguration> options)
 {
     _couchbaseConfiguration = options.Value;
 }