public static async Task <ICouchbaseCollection?> GetAtrCollection(AtrRef atrRef, ICouchbaseCollection anyCollection)
        {
            if (atrRef.BucketName == null || atrRef.CollectionName == null)
            {
                return(null);
            }

            _ = anyCollection?.Scope?.Bucket?.Name ??
                throw new ArgumentOutOfRangeException(nameof(anyCollection), "Collection was not populated.");

            if (anyCollection.Scope.Name == atrRef.ScopeName &&
                anyCollection.Scope.Bucket.Name == atrRef.BucketName &&
                anyCollection.Name == atrRef.CollectionName)
            {
                return(anyCollection);
            }

            var bkt = await anyCollection.Scope.Bucket.Cluster.BucketAsync(atrRef.BucketName).CAF();

            var scp = atrRef.ScopeName != null?bkt.Scope(atrRef.ScopeName) : bkt.DefaultScope();

            return(scp.Collection(atrRef.CollectionName));
        }
Example #2
0
 public Task <ICouchbaseCollection> GetAtrCollection(AtrRef atrRef) => Task.FromResult((ICouchbaseCollection) new MockCollectionWithNames(atrRef.CollectionName, atrRef.ScopeName, atrRef.BucketName));
 public Task <ICouchbaseCollection?> GetAtrCollection(AtrRef atrRef) => GetAtrCollection(atrRef, Collection);