Example #1
0
        public static Task CreatePrimaryAsync(this IQueryIndexes queryIndexes, string bucketName, Action <CreatePrimaryQueryIndexOptions> configureOptions)
        {
            var options = new CreatePrimaryQueryIndexOptions();

            configureOptions(options);

            return(queryIndexes.CreatePrimaryAsync(bucketName, options));
        }
        public async Task CreatePrimaryAsync(string bucketName, CreatePrimaryQueryIndexOptions options)
        {
            Logger.LogInformation($"Attempting to create primary query index on bucket {bucketName}");

            try
            {
                var statement = $"CREATE PRIMARY INDEX ON {bucketName} USING GSI WITH {{\"defer_build\":{options.Deferred}}};";
                await _queryClient.QueryAsync <dynamic>(statement,
                                                        queryOptions => queryOptions.WithCancellationToken(options.CancellationToken)
                                                        );
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Error trying to create primary query index on {bucketName}");
                throw;
            }
        }