using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; using Couchbase.Configuration.Client; using Couchbase.Core; using Couchbase.IO; namespace Couchbase.Examples.SubDocumentAPI { class Program { static void Main(string[] args) { ClusterHelper.Initialize(new ClientConfiguration { Servers = new List { new Uri(ConfigurationManager.AppSettings["couchbaseUri"]) } }); var bucket = ClusterHelper.GetBucket("default"); const string id = "puppy"; var dog = new { Type = "dog", Breed = "Pitbull/Chihuahua", Name = "Puppy", Toys = new List {"squeaker", "ball", "shoe"}, Owner = new { Type = "servant", Name = "Don Knotts", Age = 63 }, Attributes = new Dictionary { {"Fleas", true}, {"Color", "white"}, {"EyeColor", "brown"}, {"Age", 5}, {"Dirty", true }, {"Sex", "female" } }, Counts = new List { 1} }; Reset(bucket, id, dog); RemoveExample(bucket, id, "owner.namex"); ClusterHelper.Close(); Console.Read(); } static void Reset(IBucket bucket, string id, dynamic doc) { var result = bucket.Upsert(new Document { Id = id, Content = doc }); Console.WriteLine("Updated {0} - {1}", id, result.Status); } public static void RemoveExample(IBucket bucket, string id, string path) { var fragment = bucket.MutateIn(id). Remove(path). Execute(); var status = fragment.OpStatus(path); Console.WriteLine(status); } } }