public Document Save(MutableDocument document) { CBDebug.MustNotBeNull(Log.To.Database, Tag, nameof(document), document); return(ThreadSafety.DoLocked(() => { CheckOpen(); return Save(document, false); })); }
private MutableDocument([NotNull] MutableDocument other) : this((Document)other) { var dict = new MutableDictionaryObject(); if (other._dict != null) { foreach (var item in other._dict) { dict.SetValue(item.Key, MutableCopy(item.Value)); } } _dict = dict; }
public void Save(Couchbase.Lite.Linq.IDocumentModel model) { CBDebug.MustNotBeNull(Log.To.Database, Tag, nameof(model), model); ThreadSafety.DoLocked(() => { CheckOpen(); MutableDocument md = (model.Document as MutableDocument) ?? model.Document?.ToMutable() ?? new MutableDocument(); md.SetFromModel(model); try { var retVal = Save(md, false); model.Document = retVal; } finally { md.Dispose(); } }); }
public static MutableDocument ToMutableDocument <T>(this T obj, string id = null) { MutableDocument document; if (id != null) { document = new MutableDocument(id); } else { document = new MutableDocument(); } var dictionary = GetDictionary(obj); if (dictionary != null) { document.SetData(dictionary); } return(document); }