Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Supported Client Libraries

Supported Operations

OperationMethods Supported
Create
  • OpenBucket
  • OpenBucketAsync
  • GetBucket
    Insert
    • Insert
    • InsertAsync
    Update


    Expand
    titleUpdate Create Methods Supported
    • Replace
    • Upsert
    • Append
    • Prepend
    • Increment
    • Decrement
    • MutateIn
    • ReplaceAsync
    • UpsertAsync
    • AppendAsync
    • PrependAsync
    • IncrementAsync
    • DecrementAsync
    Select
    (2.x)
    • Couchbase.Cluster.OpenBucket
    • Couchbase.Core.ICluster.OpenBucket
    • Couchbase.Cluster.OpenBucketAsync
    • Couchbase.Core.ICluster.OpenBucketAsync
    • Couchbase.ClusterHelper.GetBucket
    • Couchbase.ClusterHelper.GetBucketAsync
    • Couchbase.Core.ClusterController.CreateBucket
    • Couchbase.Core.IClusterController.CreateBucket
    • Couchbase.Management.ClusterManager.CreateBucket
    • Couchbase.Management.IClusterManager.CreateBucket
    • Couchbase.Core.ClusterController.CreateBucketAsync
    • Couchbase.Core.IClusterController.CreateBucketAsync
    • Couchbase.Management.ClusterManager.CreateBucketAsync
    • Couchbase.Management.IClusterManager.CreateBucketAsync


    Expand
    titleSelect Create Methods Supported
    • Get
    • GetAndTouch
    • GetAndLock
    • GetWithLock
    • GetFromReplica
    • GetDocument
    • GetAndTouchDocument
    • GetDocumentFromReplica
    • LookupIn
    • GetAsync
    • GetAndLockAsync
    • GetAndTouchAsync
    • GetWithLockAsync
    • GetFromReplicaAsync
    • GetDocumentAsync
    • GetAndTouchDocumentAsync
    • GetDocumentFromReplicaAsync
    Delete 
    • Remove
    • RemoveAsync

    Objects

    ...

    Image Removed

    ...

    Image Removed

    ...

    Image Removed

    ...

     Image Removed

    ...

    Links are created for transaction and function point needs:

    ...

    Between Couchbase Cluster object and Couchbase Bucket object

    ...

    • OpenBucket
    • OpenBucketAsync
    • GetBucket

    ...

    • Insert
    • InsertAsync

    ...

    • Remove
    • RemoveAsync

    ...

    useSelectLink

    Expand
    titleSelect methods supported
    • Get
    • GetAndTouch
    • GetAndLock
    • GetWithLock
    • GetFromReplica
    • GetDocument
    • GetAndTouchDocument
    • GetDocumentFromReplica
    • LookupIn
    • GetAsync
    • GetAndLockAsync
    • GetAndTouchAsync
    • GetWithLockAsync
    • GetFromReplicaAsync
    • GetDocumentAsync
    • GetAndTouchDocumentAsync
    • GetDocumentFromReplicaAsync

    ...

    Expand
    titleUpdate methods supported
    • Replace
    • Upsert
    • Append
    • Prepend
    • Increment
    • Decrement
    • MutateIn
    • ReplaceAsync
    • UpsertAsync
    • AppendAsync
    • PrependAsync
    • IncrementAsync
    • DecrementAsync

    What results can you expect?

    Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.

    Cluster Creation and Bucket Opening

    Code Block
    languagec#
    titleCluster Creation and Bucket Opening
    class Program
    {        
    	private static Cluster cluster_1 = new Cluster();
            private const string bucket_name = "GeoBucket";
            private static IBucket geobucket;
            static void Main(string[] args)
            {	    
    			AuthenticateCluster();
    			CreateBucket();
    			CouchbaseOpenBucket();
    	}
            private static void AuthenticateCluster()
            {            
    			Console.WriteLine("Cluster Created - Localhost");
    			var authenticator = new PasswordAuthenticator("Administrator", "123456");
    			cluster_1.Authenticate(authenticator);
    	           
            }
            private static void CreateBucket()
            {            
    			var cm = cluster_1.CreateManager();
    			cm.CreateBucket(bucket_name);
    	}
            private static void CouchbaseOpenBucket()
            {            
    			geobucket = cluster_1.OpenBucket(bucket_name);
                	     	return;
            }
    }

    Image Removed

    Using ClusterHelper for cluster and bucket

    Code Block
    languagec#
    titleCLUSTERHELPER
    private static void TestClusterHelper4()        
    {
                var config = new ClientConfiguration {
                Servers = new List<Uri>{
    			new Uri("http://192.168.56.101:8091"),
    			new Uri("http://192.168.56.102:8091")
                }  };
                ClusterHelper.Initialize(config);
                var chbucket = ClusterHelper.GetBucket("defaultWayt");        
    }

    Image Removed

    Insert Operation

    Code Block
    languagec#
    titleInsertDocumentInBucket
    private static void InsertDocumentInBucket()        
    {
    	geobucket.Insert(SetKarDoc());
    	geobucket.Insert(SetGoaDoc());
    	geobucket.Insert(SetBengaluruDoc());
    	geobucket.Insert(SetChandigarhDoc());
    }

    Image Removed

    Update Operation

    Code Block
    languagec#
    titleReplaceDocumentInBucket
    private static void ReplaceDocumentInBucket()        
    {
    	geobucket.Replace(ModifyChandigarhDoc());        
    }

    Image Removed

    Code Block
    languagec#
    titleUpsertDocumentInBucket
    private static void UpsertDocumentInBucket()        
    {
    	geobucket.Upsert(MysuruDoc());        
    }

    Image Removed

    Decrement

    Image Removed

    Append/Prepend

    Image Removed

    Increment

    Image Removed

    Select Operation 

    Code Block
    languagec#
    titleGetDocumentFromBucket
    private static void GetDocumentsFromBucket()        
    {
    	var result = geobucket.GetDocument<dynamic>("Goa").Content;
    }

    Image Removed

    Image Removed

    Delete Operation

    Code Block
    languagec#
    titleRemoveDocumentFromBucket
    private static void DeleteDocumentInBucket()        
    {
    	geobucket.Remove(MysuruDoc());
    }        

    Image Removed

    N1QL Query

    Code Block
    languagec#
    titleUsing N1QL
    private static void QueryBucketUsingN1QL()        
    {
    	var create_index = "CREATE PRIMARY INDEX ON " + bucket_name;
    	geobucket.Query<dynamic>(create_index);
    	var queryResult = geobucket.Query<dynamic>("SELECT name, state FROM GeoBucket WHERE type = \'city\' and capital=\'Yes\'"); 
    	foreach (var row in queryResult.Rows)
    		Console.WriteLine(row);
     }

    Image Removed

    Sub-Document Operations

    The following methods sub-document operations are supported:

    • LookupIn
    • MutateIn
      • ArrayInsert
      • ArrayAppend
      • ArrayPrepend
      • ArrayAddUnique
      • Remove
      • Replace
      • Insert
      • Upsert

    LookupIn

    Code Block
    languagec#
    titleLOOKUPIN
    public static void LookupInMethod2( string id)
    {           var builder = geobucket.LookupIn<dynamic>(id).
                    Get("type").
                    Get("country").
                    Exists("notfound");       
    }
    

    Image Removed

    MutateIn

    Code Block
    languagec#
    titleMUTATEIN
    public static void SubDocMisc(string id, string path, string replace_path, object value)
    {
    	geobucket.MutateIn<dynamic>(id).
    		Remove(path).
    		Replace(replace_path, value).
    		Execute();
    }
    

    Image Removed

    Asynchronous API

    • OpenBucketAsync
    • InsertAsync
    • ReplaceAsync
    • UpsertAsync
    • AppendAsync
    • PrependAsync
    • IncrementAsync
    • DecrementAsync
    • QueryAsync
    • GetAsync
    • GetAndLockAsync
    • GetAndTouchAsync
    • GetWithLockAsync
    • GetFromReplicaAsync
    • GetDocumentAsync
    • GetAndTouchDocumentAsync
    • GetDocumentFromReplicaAsync

    Image Removed

    Evolution

    • Previously, only  files consisting of relevant Couchbase imports were processed further for analysing.
    • Support has been evolved to process a  file when it does not contain Couchbase import but makes use of its methods (APIs). Assumption here is file makes use of same namespace as used in the file containing Couchbase imports.

    Limitations

    • Cluster and bucket names are resolved as known only in the following situations:
      • Cluster/Bucket name is hardcoded
      • Cluster/Bucket name  is defined in the variable in the local method
      • Cluster/Bucket name  is defined as C# field
      • Cluster/Bucket name information is present in App.config
    • Version .NET SDK 2.1 to 2.7 are supported

    Future development

    ...

    (3.x)
    • Couchbase.IBucket.CollectionAsync
    • Couchbase.Core.BucketBase.CollectionAsync
    • Couchbase.KeyValue.IScope.CollectionAsync
    • Couchbase.KeyValue.Scope.CollectionAsync
    • Couchbase.IBucket.Collection
    • Couchbase.Core.BucketBase.Collection
    • Couchbase.KeyValue.IScope.Collection
    • Couchbase.KeyValue.Scope.Collection
    • Couchbase.IBucket.DefaultCollection
    • Couchbase.Core.BucketBase.DefaultCollection
    • Couchbase.IBucket.DefaultCollectionAsync
    • Couchbase.Core.BucketBase.DefaultCollectionAsync


    Insert


    Expand
    titleInsert Methods Supported (2.x)
    • Couchbase.CouchbaseBucket.Insert
    • Couchbase.MemcachedBucket.Insert
    • Couchbase.Core.IBucket.Insert
    • Couchbase.CouchbaseBucket.InsertAsync
    • Couchbase.MemcachedBucket.InsertAsync
    • Couchbase.Core.IBucket.InsertAsync'


    Expand
    titleInsert Methods Supported (3.x)
    • Couchbase.KeyValue.CollectionExtensions.InsertAsync
    • Couchbase.KeyValue.CouchbaseCollection.InsertAsync
    • Couchbase.KeyValue.ICouchbaseCollection.InsertAsync


    Update


    Expand
    titleUpdate Methods Supported (2.x)
    • Couchbase.CouchbaseBucket.Replace
    • Couchbase.MemcachedBucket.Replace
    • Couchbase.Core.IBucket.Replace
    • Couchbase.CouchbaseBucket.Upsert
    • Couchbase.MemcachedBucket.Upsert
    • Couchbase.Core.IBucket.Upsert
    • Couchbase.CouchbaseBucket.Append
    • Couchbase.MemcachedBucket.Append
    • Couchbase.Core.IBucket.Append
    • Couchbase.CouchbaseBucket.Prepend
    • Couchbase.MemcachedBucket.Prepend
    • Couchbase.Core.IBucket.Prepend
    • Couchbase.CouchbaseBucket.Increment
    • Couchbase.MemcachedBucket.Increment
    • Couchbase.Core.IBucket.Increment
    • Couchbase.CouchbaseBucket.Decrement
    • Couchbase.MemcachedBucket.Decrement
    • Couchbase.Core.IBucket.Decrement
    • Couchbase.CouchbaseBucket.MutateIn
    • Couchbase.MemcachedBucket.MutateIn
    • Couchbase.Core.IBucket.MutateIn
    • Couchbase.CouchbaseBucket.ReplaceAsync
    • Couchbase.MemcachedBucket.ReplaceAsync
    • Couchbase.Core.IBucket.ReplaceAsync
    • Couchbase.CouchbaseBucket.UpsertAsync
    • Couchbase.MemcachedBucket.UpsertAsync
    • Couchbase.Core.IBucket.UpsertAsync
    • Couchbase.CouchbaseBucket.AppendAsync
    • Couchbase.MemcachedBucket.AppendAsync
    • Couchbase.Core.IBucket.AppendAsync
    • Couchbase.CouchbaseBucket.PrependAsync
    • Couchbase.MemcachedBucket.PrependAsync
    • Couchbase.Core.IBucket.PrependAsync
    • Couchbase.CouchbaseBucket.IncrementAsync
    • Couchbase.MemcachedBucket.IncrementAsync
    • Couchbase.Core.IBucket.IncrementAsync
    • Couchbase.CouchbaseBucket.DecrementAsync
    • Couchbase.MemcachedBucket.DecrementAsync
    • Couchbase.Core.IBucket.DecrementAsync


    Expand
    titleUpdate Methods Supported (3.x)
    • Couchbase.KeyValue.CollectionExtensions.ReplaceAsync
    • Couchbase.KeyValue.CouchbaseCollection.ReplaceAsync
    • Couchbase.KeyValue.ICouchbaseCollection.ReplaceAsync
    • Couchbase.KeyValue.CollectionExtensions.UpsertAsync
    • Couchbase.KeyValue.CouchbaseCollection.UpsertAsync
    • Couchbase.KeyValue.ICouchbaseCollection.UpsertAsync
    • Couchbase.KeyValue.CollectionExtensions.MutateInAsync
    • Couchbase.KeyValue.CouchbaseCollection.MutateInAsync
    • Couchbase.KeyValue.ICouchbaseCollection.MutateInAsync
    • Couchbase.KeyValue.BinaryCollectionExtensions.IncrementAsync
    • Couchbase.KeyValue.CouchbaseCollection.IncrementAsync
    • Couchbase.KeyValue.IBinaryCollection.IncrementAsync
    • Couchbase.KeyValue.BinaryCollectionExtensions.DecrementAsync
    • Couchbase.KeyValue.CouchbaseCollection.DecrementAsync
    • Couchbase.KeyValue.IBinaryCollection.DecrementAsync
    • Couchbase.KeyValue.CollectionExtensions.TouchAsync
    • Couchbase.KeyValue.CouchbaseCollection.TouchAsync
    • Couchbase.KeyValue.ICouchbaseCollection.TouchAsync


    Select


    Expand
    titleSelect Methods Supported (2.x)
    • Couchbase.CouchbaseBucket.Get
    • Couchbase.MemcachedBucket.Get
    • Couchbase.Core.IBucket.Get
    • Couchbase.Cluster.QueryAsync
    • Couchbase.CouchbaseBucket.QueryAsync
    • Couchbase.MemcachedBucket.QueryAsync
    • Couchbase.Core.IBucket.QueryAsync
    • Couchbase.Core.ICluster.QueryAsync
    • Couchbase.N1QL.IQueryClient.QueryAsync
    • Couchbase.N1QL.QueryClient.QueryAsync
    • Couchbase.Search.ISearchClient.QueryAsync
    • Couchbase.Search.SearchClient.QueryAsync
    • Couchbase.Cluster.Query
    • Couchbase.CouchbaseBucket.Query
    • Couchbase.MemcachedBucket.Query
    • Couchbase.Core.IBucket.Query
    • Couchbase.Core.ICluster.Query
    • Couchbase.N1QL.IQueryClient.Query
    • Couchbase.N1QL.QueryClient.Query
    • Couchbase.Search.ISearchClient.Query
    • Couchbase.Search.SearchClient.Query
    • Couchbase.CouchbaseBucket.GetAndTouch
    • Couchbase.MemcachedBucket.GetAndTouch
    • Couchbase.Core.IBucket.GetAndTouch
    • Couchbase.CouchbaseBucket.GetAndLock
    • Couchbase.MemcachedBucket.GetAndLock
    • Couchbase.Core.IBucket.GetAndLock
    • Couchbase.CouchbaseBucket.GetWithLock
    • Couchbase.MemcachedBucket.GetWithLock
    • Couchbase.Core.IBucket.GetWithLock
    • Couchbase.CouchbaseBucket.GetFromReplica
    • Couchbase.MemcachedBucket.GetFromReplica
    • Couchbase.Core.IBucket.GetFromReplica
    • Couchbase.CouchbaseBucket.GetDocument
    • Couchbase.MemcachedBucket.GetDocument
    • Couchbase.Core.IBucket.GetDocument
    • Couchbase.CouchbaseBucket.GetAndTouchDocument
    • Couchbase.MemcachedBucket.GetAndTouchDocument
    • Couchbase.Core.IBucket.GetAndTouchDocument
    • Couchbase.CouchbaseBucket.GetDocumentFromReplica
    • Couchbase.MemcachedBucket.GetDocumentFromReplica
    • Couchbase.Core.IBucket.GetDocumentFromReplica
    • Couchbase.CouchbaseBucket.LookupIn
    • Couchbase.MemcachedBucket.LookupIn
    • Couchbase.Core.IBucket.LookupIn
    • Couchbase.CouchbaseBucket.GetAsync
    • Couchbase.MemcachedBucket.GetAsync
    • Couchbase.Core.IBucket.GetAsync
    • Couchbase.CouchbaseBucket.GetAndLockAsync
    • Couchbase.MemcachedBucket.GetAndLockAsync
    • Couchbase.Core.IBucket.GetAndLockAsync
    • Couchbase.CouchbaseBucket.GetAndTouchAsync
    • Couchbase.MemcachedBucket.GetAndTouchAsync
    • Couchbase.Core.IBucket.GetAndTouchAsync
    • Couchbase.CouchbaseBucket.GetWithLockAsync
    • Couchbase.MemcachedBucket.GetWithLockAsync
    • Couchbase.Core.IBucket.GetWithLockAsync
    • Couchbase.CouchbaseBucket.GetFromReplicaAsync
    • Couchbase.MemcachedBucket.GetFromReplicaAsync
    • Couchbase.Core.IBucket.GetFromReplicaAsync
    • Couchbase.CouchbaseBucket.GetDocumentAsync
    • Couchbase.MemcachedBucket.GetDocumentAsync
    • Couchbase.Core.IBucket.GetDocumentAsync
    • Couchbase.CouchbaseBucket.GetAndTouchDocumentAsync
    • Couchbase.MemcachedBucket.GetAndTouchDocumentAsync
    • Couchbase.Core.IBucket.GetAndTouchDocumentAsync
    • Couchbase.CouchbaseBucket.GetDocumentFromReplicaAsync
    • Couchbase.MemcachedBucket.GetDocumentFromReplicaAsync
    • Couchbase.Core.IBucket.GetDocumentFromReplicaAsync


    Expand
    titleSelect Methods Supported (3.x)
    • Couchbase.KeyValue.CollectionExtensions.GetAsync
    • Couchbase.KeyValue.CouchbaseCollection.GetAsync
    • Couchbase.KeyValue.ICouchbaseCollection.GetAsync
    • Couchbase.Cluster.QueryAsync
    • Couchbase.ICluster.QueryAsync
    • Couchbase.KeyValue.CollectionExtensions.LookupInAsync
    • Couchbase.KeyValue.CouchbaseCollection.LookupInAsync
    • Couchbase.KeyValue.ICouchbaseCollection.LookupInAsync,
    • Couchbase.KeyValue.CollectionExtensions.GetAndTouchAsync
    • Couchbase.KeyValue.CouchbaseCollection.GetAndTouchAsync
    • Couchbase.KeyValue.ICouchbaseCollection.GetAndTouchAsync
    • Couchbase.KeyValue.CollectionExtensions.GetAndLockAsync
    • Couchbase.KeyValue.CouchbaseCollection.GetAndLockAsync
    • Couchbase.KeyValue.ICouchbaseCollection.GetAndLockAsync


    Delete 


    Expand
    titleDelete Methods Supported (2.x)
    • Couchbase.CouchbaseBucket.Remove
    • Couchbase.MemcachedBucket.Remove
    • Couchbase.Core.IBucket.Remove
    • Couchbase.CouchbaseBucket.RemoveAsync
    • Couchbase.MemcachedBucket.RemoveAsync
    • Couchbase.Core.IBucket.RemoveAsync


    Expand
    titleDelete Methods Supported (3.x)
    • Couchbase.KeyValue.CollectionExtensions.RemoveAsync
    • Couchbase.KeyValue.CouchbaseCollection.RemoveAsync
    • Couchbase.KeyValue.ICouchbaseCollection.RemoveAsync


    Objects

    Icon Description

    Image Added

    DotNet Couchbase Cluster

    Image Added

    DotNet Couchbase Bucket

    Image Added

    DotNet Couchbase Collection

    Image Added

    DotNet Unknown Cluster

     Image Added

    DotNet Unknown Couchbase Bucket 

    Image Added

    DotNet Unknown Couchbase Collection

    Links are created for transaction and function point needs:

    Link typeSource and destination of link Methods supported
    belongsTo

    From DotNet Couchbase Bucket object to DotNet Couchbase Cluster object



    useLinkBetween the caller .NET Class / Method objects and DotNet Couchbase Buckets/Collections objects


    • OpenBucket
    • OpenBucketAsync
    • GetBucket
    • GetBucketAsync
    • CreateBucket
    • CreateBucketAsync
    • CollectionAsync
    • Collection
    • DefaultCollection
    • DefaultCollectionAsync
     useInsertLink
    • Insert
    • InsertAsync
     useDeleteLink
    • Remove
    • RemoveAsync

    useSelectLink


    Expand
    titleSelect Methods Supported
    • Get
    • GetAndTouch
    • GetAndLock
    • GetWithLock
    • GetFromReplica
    • GetDocument
    • GetAndTouchDocument
    • GetDocumentFromReplica
    • LookupIn
    • GetAsync
    • LookupInAsync
    • GetAndLockAsync
    • GetAndTouchAsync
    • GetWithLockAsync
    • GetFromReplicaAsync
    • GetDocumentAsync
    • GetAndTouchDocumentAsync
    • GetDocumentFromReplicaAsync


    useUpdateLink


    Expand
    titleUpdate Methods Supported
    • Replace
    • Upsert
    • Append
    • Prepend
    • Increment
    • Decrement
    • MutateIn
    • MutateInAsync
    • ReplaceAsync
    • UpsertAsync
    • AppendAsync
    • PrependAsync
    • IncrementAsync
    • DecrementAsync
    • TouchAsync


    What results can you expect?

    Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.

    Cluster Creation and Bucket Opening (2.x)

    Code Block
    languagec#
    titleCluster Creation and Bucket Opening
    class Program
    {        
    	private static Cluster cluster_1 = new Cluster();
            private const string bucket_name = "GeoBucket";
            private static IBucket geobucket;
            static void Main(string[] args)
            {	    
    			AuthenticateCluster();
    			CreateBucket();
    			CouchbaseOpenBucket();
    	}
            private static void AuthenticateCluster()
            {            
    			Console.WriteLine("Cluster Created - Localhost");
    			var authenticator = new PasswordAuthenticator("Administrator", "123456");
    			cluster_1.Authenticate(authenticator);
    	           
            }
            private static void CreateBucket()
            {            
    			var cm = cluster_1.CreateManager();
    			cm.CreateBucket(bucket_name);
    	}
            private static void CouchbaseOpenBucket()
            {            
    			geobucket = cluster_1.OpenBucket(bucket_name);
                	     	return;
            }
    }


    Image Added

    Using ClusterHelper for cluster and bucket (2.x)

    Code Block
    languagec#
    titleCLUSTERHELPER
    private static void TestClusterHelper4()        
    {
                var config = new ClientConfiguration {
                Servers = new List<Uri>{
    			new Uri("http://192.168.56.101:8091"),
    			new Uri("http://192.168.56.102:8091")
                }  };
                ClusterHelper.Initialize(config);
                var chbucket = ClusterHelper.GetBucket("defaultWayt");        
    }

    Image Added

    Cluster, Bucket and Collection Creation (3.x)

    Code Block
    languagec#
    titleCluster Creation and Bucket Opening
    class Program
    {        
    	private const string users_collection = "collection6";
    
    	public async Task<Employees> GetTheDoc(Employees value)
            {
    			var cluster4 = await Cluster.ConnectAsync("couchbase://localhost", "adm", "jim753");
                var bucket = await cluster4.BucketAsync("NewBucket");
    
                // get a user-defined collection reference
                var scope = await bucket.ScopeAsync("tenant_agent_00");
                var collection = await scope.CollectionAsync(users_collection);
                
                var collection_in_default_scope = await bucket.CollectionAsync("bookings");
            }
    }


    Image Added

    Image Added

    Insert Operation (2.x)

    Code Block
    languagec#
    titleInsertDocumentInBucket
    private static void InsertDocumentInBucket()        
    {
    	geobucket.Insert(SetKarDoc());
    	geobucket.Insert(SetGoaDoc());
    	geobucket.Insert(SetBengaluruDoc());
    	geobucket.Insert(SetChandigarhDoc());
    }

    Image Added

    Insert Operation (3.x)

    Code Block
    languagec#
    titleInsertDocumentInBucket
    //create
            public async Task<Employees> PostEmployee(ICluster cluster3, Employees value)
            {
                var bucket = await cluster3.BucketAsync(samplebucket);
                var collection = bucket.DefaultCollection();
                
                // You can access multiple buckets using the same Cluster object.
    			var anotherBucket = await cluster3.BucketAsync("AnotherBucket");
    			
    			// You can access collections other than the default
    			var customerC = anotherBucket.Scope("customer-c");
    			var trains = customerC.Collection("trains");
    			
                int idvalue = value.id;
                var collectiondataa= await trains.InsertAsync( idvalue.ToString(),value );
                if (collectiondataa == null)
                {
                    logger.LogError("Error in creating");
                }
                return null;
            }

    Image Added

    Image Added

    Update Operation (2.x)

    Code Block
    languagec#
    titleReplaceDocumentInBucket
    private static void ReplaceDocumentInBucket()        
    {
    	geobucket.Replace(ModifyChandigarhDoc());        
    }

    Image Added

    Code Block
    languagec#
    titleUpsertDocumentInBucket
    private static void UpsertDocumentInBucket()        
    {
    	geobucket.Upsert(MysuruDoc());        
    }

    Image Added

    Decrement

    Image Added

    Append/Prepend

    Image Added

    Increment

    Image Added

    Update Operation (3.x)

    Code Block
    languagec#
    titleReplaceDocumentInBucket
    //update
            public async Task<Employees> OnlyUpdateEmployee(ICluster cluster_new_2, Employees value)
            {
                var bucket = await cluster_new_2.BucketAsync("SmallBucket");
                var collection = bucket.DefaultCollection();
                
                // You can access multiple buckets using the same Cluster object.
    			var anotherBucket = await cluster_new_2.BucketAsync("ShiningBucket");
    			
    			// You can access collections other than the default
    			var customerD = anotherBucket.Scope("customer-D");
    			var bikes = customerD.Collection("bikes");
    			
                int idvalue = value.id;
                var collectiondataa= await bikes.ReplaceAsync( idvalue.ToString(),value );
                if (collectiondataa == null)
                {
                    logger.LogError("Error in creating");
                }
                return null;
            }

    Image Added

    Image Added

    Select Operation (2.x)

    Code Block
    languagec#
    titleGetDocumentFromBucket
    private static void GetDocumentsFromBucket()        
    {
    	var result = geobucket.GetDocument<dynamic>("Goa").Content;
    }

    Image Added

    Image Added

    Select Operation (3.x)

    Code Block
    languagec#
    titleGetDocumentFromBucket
    //get
            public async Task<Employees> GetTheDoc(ICluster cluster4, Employees value)
            {
                var bucket = await cluster4.BucketAsync(newbucket);
    
                // get a user-defined collection reference
                var scope = await bucket.ScopeAsync("tenant_agent_00");
                var collection = await scope.CollectionAsync(users_collection);
                
                var collection_in_default_scope = await bucket.CollectionAsync("bookings");
    
                // Get Document
                var getResult = await collection.GetAsync("my-document-key");
            }

    Image Added

    Image Added

    Delete Operation (2.x)

    Code Block
    languagec#
    titleRemoveDocumentFromBucket
    private static void DeleteDocumentInBucket()        
    {
    	geobucket.Remove(MysuruDoc());
    }        

    Image Added

    Delete Operation (3.x)

    Code Block
    languagec#
    titleRemoveDocumentFromBucket
    public async Task<Employees> DeleteEmployeeById(ICluster cluster1, int id)
            {
                try
                {
                    var bucket = await cluster1.BucketAsync("EmployeesBucket");
    			
    				// You can access collections other than the default
    				var customer10 = bucket.Scope("customer-10");
    				var bluecolour = customer10.Collection("bluecolour");
    	       
    	            int idvalue = value.id;
    	            var collectiondataa = await bluecolour.RemoveAsync( idvalue.ToString() );
    	            if (collectiondataa == null)
    	            {
    	                logger.LogError("Error in creating");
    	            }
    	            return null;
                }
                catch (BucketNotFoundException)
                {
                    logger.LogError("Bucket not found");
                    throw;
                }
            
            }      

    Image Added

    Image Added

    N1QL Query (2.x)

    Code Block
    languagec#
    titleUsing N1QL
    private static void QueryBucketUsingN1QL()        
    {
    	var create_index = "CREATE PRIMARY INDEX ON " + bucket_name;
    	geobucket.Query<dynamic>(create_index);
    	var queryResult = geobucket.Query<dynamic>("SELECT name, state FROM GeoBucket WHERE type = \'city\' and capital=\'Yes\'"); 
    	foreach (var row in queryResult.Rows)
    		Console.WriteLine(row);
     }

    Image Added

    Image Added

    N1QL Query (3.x)

    Code Block
    languagec#
    titleUsing N1QL
    public async Task<List<Employees>> GetEmployees(ICluster cluster_query)
            {
                try
                {
                    var queryResult = await cluster_query.QueryAsync<Employees>("SELECT username,name,email,age,location,srccs,phoneNumber,salary,skill,managerName,address,id FROM Employees ", new Couchbase.Query.QueryOptions());
    				var queryResult2 = await cluster_query.QueryAsync<Employees>("UPDATE cars SET door = red, window = transparent, WHERE door = blue; ", new Couchbase.Query.QueryOptions());
                    List<Employees> empList = new List<Employees>();
    
                    await foreach (var row in queryResult)
                    {
                        empList.Add(row);
                    }
    
                    return empList;
    
                }
                catch (IndexFailureException)
                {
                    logger.LogError("Bucket not found");
                    throw;
                }
               
    
            }

    Image Added

    Image Added

    Sub-Document Operations

    The following methods sub-document operations are supported:

    • LookupIn
    • MutateIn
      • ArrayInsert
      • ArrayAppend
      • ArrayPrepend
      • ArrayAddUnique
      • Remove
      • Replace
      • Insert
      • Upsert

    LookupIn

    Code Block
    languagec#
    titleLOOKUPIN
    public static void LookupInMethod2( string id)
    {           var builder = geobucket.LookupIn<dynamic>(id).
                    Get("type").
                    Get("country").
                    Exists("notfound");       
    }
    

    Image Added

    MutateIn

    Code Block
    languagec#
    titleMUTATEIN
    public static void SubDocMisc(string id, string path, string replace_path, object value)
    {
    	geobucket.MutateIn<dynamic>(id).
    		Remove(path).
    		Replace(replace_path, value).
    		Execute();
    }
    

    Image Added

    Image Added

    Asynchronus API

    Expand
    titleAsynchronus APIs
    • OpenBucketAsync
    • GetBucketAsync
    • CreateBucketAsync
    • CollectionAsync
    • DefaultCollectionAsync
    • InsertAsync
    • ReplaceAsync
    • UpsertAsync
    • AppendAsync
    • PrependAsync
    • IncrementAsync
    • DecrementAsync
    • QueryAsync
    • GetAsync
    • GetAndLockAsync
    • GetAndTouchAsync
    • GetWithLockAsync
    • GetFromReplicaAsync
    • GetDocumentAsync
    • GetAndTouchDocumentAsync
    • GetDocumentFromReplicaAsync
    • TouchAsync
    • LookupInAsync
    • MutateInAsync
    • QueryAsync

    Image Added

    Reading App.config

    Expand
    titleApp.config


    Code Block
    languagec#
    titleIncrement Operation 2.x
    static void Increment(IBucket bucket1, string key)
            {
                var result = bucket1.Increment(key);
                if (result.Success)
                {
                    Console.WriteLine(result.Value);
                }
            }


    Code Block
    languagexml
    titleapp.config
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
        </startup>
      <configSections>
        <sectionGroup name="couchbaseClients">
          <section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
        </sectionGroup>
      </configSections>
      <couchbaseClients>
        <couchbase username="Administrator" password="123456">
          <servers>
            <add uri="http://192.168.56.101:8091"></add>
            </servers>
          <buckets>
            <add name="mybucket"></add>
    		<add name="mybucket2"></add>
          </buckets>
        </couchbase>
      </couchbaseClients>
    </configuration>


    Image Added

    Evolution

    • Support for Couchbase 3.x, which has 3 layers - Clusters, Buckets and Collections.
    • Better evaluation of object names.
    • Reading of Cluster/Bucket from configuration files for Couchbase 2.x

    Limitations

    • If bucket/collection names are not resolved, the links are created between methods and unknown bucket/collection objects