private static void createDocs(Couchbase.Core.IBucket bucket) { for (int i = 0; i <= DOC_COUNT; i++) { var document = new Document <dynamic> { Id = i.ToString(), Content = new { name = "Couchbase test application" } }; //Console.WriteLine(document.Id); var upsert = bucket.Upsert(document); // Console.WriteLine(upsert.Status); if (upsert.Success) { var get = bucket.GetDocument <dynamic>(i.ToString()); document = get.Document; //var msg = string.Format("{0} {1}!", document.Id, document.Content.name); //Console.WriteLine(msg); } } }
public T Read <T>(string id) where T : ObjectSchema.IFromJson <T>, ObjectSchema.IObject, new() { var get = _bucket.GetDocument <dynamic>(id); if (!get.Success) { throw new KeyNotFoundException(String.Format("Failed to retrieve document: {0}", id)); } var document = get.Document; T obj = new T(); obj.FromJson(document.Content, ref obj); obj.id = document.Id; return(obj); }