/// <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()); }
/// <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 db, string id, string view, string key, bool include_doc = false) { string result = DoRequest(_server + "/" + db + "/_design/" + id + "/_view/" + view + "?include_docs=" + include_doc.ToString().ToLower() + "&key=%22" + key + "%22", "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.Key = row["key"].ToJson(); doc.Revision = (row["value"])["rev"].ToString(); if (include_doc) { doc.Document = row["doc"].ToJson(); } list.Add(doc); } return(list.ToArray()); }
/// <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 db, string id, string view, string startkey, int count, out int total, bool include_doc = false) { string result = DoRequest(_server + "/" + db + "/_design/" + id + "/_view/" + view + "?include_docs=" + include_doc.ToString().ToLower() + "&limit=" + count.ToString() + (startkey == null ? "" : "&startkey=%22" + startkey.Trim(new[] { '"' }) + "%22"), "GET"); List <DocInfo> list = new List <DocInfo>(); JsonData d = JsonMapper.ToObject(result); total = (int)d["total_rows"]; foreach (JsonData row in d["rows"]) { DocInfo doc = new DocInfo(); doc.Id = row["id"].ToString(); doc.Key = row["key"].ToJson(); doc.Revision = (row["value"])["rev"].ToString(); if (include_doc) { doc.Document = row["doc"].ToJson(); } list.Add(doc); } return(list.ToArray()); }
/// <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(); }
/// <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 db, string id, string view, string startkey, int count, out int total, bool include_doc=false) { string result = DoRequest(_server + "/" + db + "/_design/" + id + "/_view/" + view + "?include_docs=" + include_doc.ToString().ToLower() + "&limit=" + count.ToString() + (startkey == null ? "" : "&startkey=%22" + startkey.Trim(new[] { '"' }) + "%22"), "GET"); List<DocInfo> list = new List<DocInfo>(); JsonData d = JsonMapper.ToObject(result); total = (int)d["total_rows"]; foreach (JsonData row in d["rows"]) { DocInfo doc = new DocInfo(); doc.Id = row["id"].ToString(); doc.Key = row["key"].ToJson(); doc.Revision = (row["value"])["rev"].ToString(); if (include_doc) doc.Document = row["doc"].ToJson(); list.Add(doc); } return list.ToArray(); }
/// <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 db, string id, string view, string[] keys, bool include_doc = false) { string key = String.Format("[{0}]", string.Join(",", keys.Select(k => String.Format("\"{0}\"", k)).ToArray())); string result = DoRequest(_server + "/" + db + "/_design/" + id + "/_view/" + view + "?include_docs=" + include_doc.ToString().ToLower() + "&key=" + key, "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.Key = row["key"].ToJson(); doc.Revision = (row["value"])["rev"].ToString(); if (include_doc) doc.Document = row["doc"].ToJson(); list.Add(doc); } return list.ToArray(); }