Exemplo n.º 1
0
        public async Task DropCollectionAsync(CollectionSpec spec, DropCollectionOptions options)
        {
            var uri = GetUri(spec.ScopeName, spec.Name);

            Logger.LogInformation($"Attempting drop collection {spec.ScopeName}/{spec.Name} - {uri}");

            try
            {
                // check collection exists
                var collectionExists =
                    await CollectionExistsAsync(spec, new CollectionExistsOptions { CancellationToken = options.CancellationToken })
                    .ConfigureAwait(false);

                if (!collectionExists)
                {
                    throw new CollectionNotFoundException(spec.ScopeName, spec.Name);
                }

                // drop collection
                var createResult = await _client.DeleteAsync(uri, options.CancellationToken).ConfigureAwait(false);

                createResult.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to drop collection {spec.ScopeName}/{spec.Name} - {uri}");
                throw;
            }
        }
Exemplo n.º 2
0
        public static Task DropCollectionAsync(this ICollectionManager manager, CollectionSpec spec, Action <DropCollectionOptions> configureOptions)
        {
            var options = new DropCollectionOptions();

            configureOptions(options);

            return(manager.DropCollectionAsync(spec, options));
        }
Exemplo n.º 3
0
        public async Task DropCollectionAsync(CollectionSpec spec, DropCollectionOptions options = null)
        {
            options ??= DropCollectionOptions.Default;
            var uri = GetUri(spec.ScopeName, spec.Name);

            Logger.LogInformation($"Attempting drop collection {spec.ScopeName}/{spec.Name} - {uri}");

            try
            {
                // drop collection
                var createResult = await _client.DeleteAsync(uri, options.TokenValue).ConfigureAwait(false);

                createResult.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to drop collection {spec.ScopeName}/{spec.Name} - {uri}");
                throw;
            }
        }
 // public constructors
 public JsonDrivenDropCollectionTest(IMongoDatabase database, Dictionary <string, object> objectMap)
     : base(database, objectMap)
 {
     _dropCollectionOptions = new DropCollectionOptions();
 }