public static Task <IMutateInResult <TDocument> > MutateInAsync <TDocument>(this ICouchbaseCollection collection,
                                                                                    string id, Action <MutateInSpecBuilder <TDocument> > configureBuilder, Action <MutateInOptions> configureOptions)
        {
            var options = new MutateInOptions();

            configureOptions(options);

            return(collection.MutateInAsync(id, configureBuilder, options));
        }
        public static Task <IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id,
                                                           IEnumerable <MutateInSpec> specs, Action <MutateInOptions> configureOptions)
        {
            var options = new MutateInOptions();

            configureOptions(options);

            return(collection.MutateInAsync(id, specs, options));
        }
        public static Task <IMutateInResult> MutateInAsync(this ICouchbaseCollection 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));
        }
示例#4
0
        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 async Task <IMutationResult> MutateInAsync(string id, IEnumerable <OperationSpec> specs, MutateInOptions options)
        {
            // convert new style specs into old style builder
            var builder = new MutateInBuilder <byte[]>(null, null, id, specs);

            //resolve StoreSemantics to SubdocDocFlags
            var docFlags = SubdocDocFlags.None;

            switch (options.StoreSemantics)
            {
            case StoreSemantics.Replace:
                break;

            case StoreSemantics.Upsert:
                docFlags |= SubdocDocFlags.UpsertDocument;
                break;

            case StoreSemantics.Insert:
                docFlags |= SubdocDocFlags.InsertDocument;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            using (var mutation = new MultiMutation <byte[]>
            {
                Key = id,
                Builder = builder,
                Cid = Cid,
                DurabilityLevel = options.DurabilityLevel,
                Transcoder = _transcoder,
                DocFlags = docFlags
            })
            {
                await _bucket.SendAsync(mutation, options.Token, options.Timeout);

                return(new MutationResult(mutation.Cas, null, mutation.MutationToken));
            }
        }