Ejemplo n.º 1
0
        public static MutateInSpecBuilder Decrement <T>(this MutateInSpecBuilder builder, string path, long delta, Action <MutateInDecrementOptions> configureOptions)
        {
            var options = new MutateInDecrementOptions();

            configureOptions?.Invoke(options);

            return(builder.Decrement(path, delta, options.CreatePath, options.XAttr));
        }
Ejemplo n.º 2
0
        public static MutateInSpecBuilder AddUnique <T>(this MutateInSpecBuilder builder, string path, T value, Action <MutateInArrayAddUniqueOptions> configureOptions)
        {
            var options = new MutateInArrayAddUniqueOptions();

            configureOptions?.Invoke(options);

            return(builder.ArrayAddUnique(path, value, options.CreatePath, options.XAttr));
        }
Ejemplo n.º 3
0
        public static MutateInSpecBuilder Insert <T>(this MutateInSpecBuilder builder, string path, T value, Action <MutateInInsertOptions> configureOptions)
        {
            var options = new MutateInInsertOptions();

            configureOptions?.Invoke(options);

            return(builder.Insert(path, value, options.CreatePath, options.XAttr));
        }
Ejemplo n.º 4
0
        public static MutateInSpecBuilder Remove <T>(this MutateInSpecBuilder builder, string path, T value, Action <MutateInRemoveOptions> configureOptions)
        {
            var options = new MutateInRemoveOptions();

            configureOptions?.Invoke(options);

            return(builder.Remove(path, options.XAttr));
        }
        public static Task <IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id,
                                                           Action <MutateInSpecBuilder> configureBuilder, MutateInOptions?options)
        {
            var mutateInSpec = new MutateInSpecBuilder();

            configureBuilder(mutateInSpec);

            return(collection.MutateInAsync(id, mutateInSpec.Specs, options));
        }
        public static Task <IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id,
                                                           Action <MutateInSpecBuilder> configureBuilder)
        {
            var builder = new MutateInSpecBuilder();

            configureBuilder(builder);

            return(collection.MutateInAsync(id, builder.Specs, MutateInOptions.Default));
        }
        public static Task <IMutationResult> MutateInAsync(this ICollection collection, string id,
                                                           Action <MutateInSpecBuilder> configureBuilder, Action <MutateInOptions> configureOptions)
        {
            var builder = new MutateInSpecBuilder();

            configureBuilder(builder);

            var options = new MutateInOptions();

            configureOptions(options);

            return(collection.MutateInAsync(id, builder.Specs, options));
        }
        public static async Task <IMutateInResult <TDocument> > MutateInAsync <TDocument>(
            this ICouchbaseCollection collection, string id, Action <MutateInSpecBuilder <TDocument> > configureBuilder,
            MutateInOptions?options = null)
        {
            var serializer = options?.SerializerValue ??
                             collection.Scope.Bucket.Cluster.ClusterServices.GetRequiredService <ITypeSerializer>();

            var mutateInSpec = new MutateInSpecBuilder <TDocument>(serializer);

            configureBuilder(mutateInSpec);

            return(new MutateInResult <TDocument>(
                       await collection.MutateInAsync(id, mutateInSpec.Specs, options).ConfigureAwait(false)));
        }
Ejemplo n.º 9
0
        public static MutateInSpecBuilder <TDocument> Replace <TDocument, TContent>(this MutateInSpecBuilder <TDocument> builder,
                                                                                    Expression <Func <TDocument, TContent> > path, TContent value)
        {
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (builder == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(builder));
            }
            if (path == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(path));
            }
            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            return((MutateInSpecBuilder <TDocument>)
                   builder.Replace(SubDocumentPathExpressionVisitor.GetPath(builder, path), value));
        }
Ejemplo n.º 10
0
        public static MutateInSpecBuilder <TDocument> Decrement <TDocument, TContent>(this MutateInSpecBuilder <TDocument> builder,
                                                                                      Expression <Func <TDocument, TContent> > path, long delta, bool createPath = false)
        {
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (builder == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(builder));
            }
            if (path == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(path));
            }
            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            return((MutateInSpecBuilder <TDocument>)
                   builder.Decrement(SubDocumentPathExpressionVisitor.GetPath(builder, path), delta, createPath));
        }
Ejemplo n.º 11
0
        public static MutateInSpecBuilder <TDocument> ArrayAddUnique <TDocument, TContent, TElement>(this MutateInSpecBuilder <TDocument> builder,
                                                                                                     Expression <Func <TDocument, TContent> > path, TElement value, bool createPath = false)
            where TContent : ICollection <TElement>
        {
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (builder == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(builder));
            }
            if (path == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(path));
            }
            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            return((MutateInSpecBuilder <TDocument>)
                   builder.ArrayAddUnique(SubDocumentPathExpressionVisitor.GetPath(builder, path), value, createPath));
        }