public async Task <bool> CollectionExistsAsync(CollectionSpec spec, CollectionExistsOptions options = null) { options ??= CollectionExistsOptions.Default; var uri = GetUri(); Logger.LogInformation($"Attempting to verify if scope/collection {spec.ScopeName}/{spec.Name} exists - {uri}"); try { // get all scopes var scopes = await GetAllScopesAsync(new GetAllScopesOptions().CancellationToken(options.TokenValue)) .ConfigureAwait(false); // try find scope / collection return(scopes.Any(scope => scope.Name == spec.ScopeName && scope.Collections.Any(collection => collection.Name == spec.Name) )); } catch (Exception exception) { Logger.LogError(exception, $"Failed to verify if collection {spec.ScopeName}/{spec.Name} exists - {uri}"); throw; } }
public static Task <bool> CollectionExistsAsync(this ICollectionManager manager, CollectionSpec spec, Action <CollectionExistsOptions> configureOptions) { var options = new CollectionExistsOptions(); configureOptions(options); return(manager.CollectionExistsAsync(spec, options)); }