Used to return metadata about a document.
Example #1
0
        /// <summary>
        /// Get information on all the documents in the given database.
        /// </summary>
        /// <param name="server">The server URL</param>
        /// <param name="db">The database name</param>
        /// <returns>An array of DocInfo instances</returns>
        public DocInfo[] GetAllDocuments(string server, string db)
        {
            string result = DoRequest(server + "/" + db + "/_all_docs", "GET");

            List <DocInfo> list = new List <DocInfo>();

            JsonData d = JsonMapper.ToObject(result);

            foreach (JsonData row in d["rows"])
            {
                DocInfo doc = new DocInfo();
                doc.ID       = row["id"].ToString();
                doc.Revision = (row["value"])["rev"].ToString();
                list.Add(doc);
            }
            return(list.ToArray());
        }
Example #2
0
        public string RevsDiff(NDB.NouchDB db, RemoteDB remoteDB, DocInfo[] docInfo)
        {
            var result = "[";
            Dictionary<string,string> docList = new Dictionary<string,string>();

            for (int f = 0; f < docInfo.Length; f++ )
            {
                DocInfo remoteDoc = docInfo[f];
                long revision = Convert.ToInt64(remoteDoc.Revision.Split('-')[0]);
                Node localDoc = db.GetDocInfo(remoteDoc.ID);

                if (localDoc == null)
                {
                    if (Convert.ToInt64(localDoc.currentVersion) < revision)
                    {
                        if (!docList.ContainsKey(remoteDoc.ID))
                        {
                            docList.Add(remoteDoc.ID,"");
                        }
                    }

                }
                else
                {
                    if (!docList.ContainsKey(remoteDoc.ID))
                    {
                        docList.Add(remoteDoc.ID, "");
                    }
                }

            }

            return JsonMapper.ToJson(docList.Keys);
        }
Example #3
0
        /// <summary>
        /// Get information on all the documents in the given database.
        /// </summary>
        /// <param name="server">The server URL</param>
        /// <param name="db">The database name</param>
        /// <returns>An array of DocInfo instances</returns>
        public DocInfo[] GetAllDocuments(string server, string db)
        {
            string result = DoRequest(server + "/" + db + "/_all_docs", "GET");

            List<DocInfo> list = new List<DocInfo>();

            JsonData d = JsonMapper.ToObject(result);
            foreach (JsonData row in d["rows"])
            {
                DocInfo doc = new DocInfo();
                doc.ID = row["id"].ToString();
                doc.Revision = (row["value"])["rev"].ToString();
                list.Add(doc);
            }
            return list.ToArray();
        }