public Node GetDocInfo(string docId, string rev_id = "") { Node docInfo = null; string docInfoString = docStore.Get(ReadOptions.Default, docId).ToString(); if (docInfoString != null) { docInfo = Node.Parse(docInfoString); } return(docInfo); }
public string GetDoc(string docId) { string result = ""; string docInfoString = docStore.Get(ReadOptions.Default, docId).ToString(); Node docInfo = Node.Parse(docInfoString); long latestSequence = docInfo.getLatestSequence(); result = sequenceStore.Get(ReadOptions.Default, latestSequence.ToString()).ToString(); result = result.Split('+')[1]; return(result); }
/// <summary> /// Update or insert a new document into the database /// </summary> /// <param name="docId">ID of the document to store or update</param> /// <param name="data">string data for the associated document</param> /// <param name="revId">specific version add by revId </param> public void PutDoc(string docId, string data, string revId) { Node docInfo = null; try { // If possible try and retrieve any existing doc info for this id string docInfoString = docStore.Get(ReadOptions.Default, docId).ToString(); if (docInfoString == null) { // Insert mode: create a new root document docInfo = new Node(docId, data, sequenceCount, revId); docCount = docCounter.Next(); } else { // Update mode: create a new revision entry docInfo = Node.Parse(docInfoString); // add a new document version if (docInfo.addVersion(data, sequenceCount, revId) == null) { return; } } // Store info about the document in the doc store //Debug.WriteLine(docInfo.Dump()); string docInfoData = docInfo.ToJson(); docInfoData = docInfoData.Replace("\"", ""); docStore.Put(WriteOptions.Default, docId, docInfoData); // store a unique uuid linked with the doc id data sequenceStore.Put(WriteOptions.Default, sequenceCount.ToString(), docInfo.getLatestSig() + "+" + data); sequenceCount = sequenceCounter.Next(); } catch (Exception ee) { throw ee; } finally { } }