/// <summary> /// Returns a JSON structure of the documents in a given database, found by ID list. /// The information is returned as a JSON structure containing meta information /// about the return structure, including a list of all documents and basic contents, /// consisting the ID, revision and key. The key is the from the document’s _id. /// </summary> /// <param name="docIdList">Array of document IDs to be retrieved.</param> /// <param name="queryParams">Instance of <see cref="ListQueryParams"/> to be used for filtering.</param> /// <returns><see cref="DocListResponse{STRING}"/> containing list of JSON strings.</returns> /// <exception cref="ArgumentNullException">Required parameter is null or empty.</exception> /// <exception cref="CouchDBClientException">Error response received from CouchDB server.</exception> /// <exception cref="InvalidOperationException">Malformed JSON string received from CouchDB server..</exception> public async Task <DocListResponse <string> > GetStringDocumentsAsync(string[] docIdList, ListQueryParams queryParams = null) { if (docIdList == null || docIdList.Length == 0) { throw new ArgumentNullException(nameof(docIdList)); } if (queryParams == null) { queryParams = new ListQueryParams(); } var allDocsUrl = QueryParams.AppendQueryParams("_all_docs", queryParams); var allDocsRequest = new { keys = docIdList }; var allDocsJsonRequest = JsonConvert.SerializeObject(allDocsRequest); var allDocsResponse = await _handler.SendRequestAsync(allDocsUrl, RequestMethod.POST, Request.JsonString(allDocsJsonRequest)).Safe(); if (allDocsResponse == null) { return(null); } var allDocsJsonString = await allDocsResponse.ReadAsStringAsync(false).Safe(); var docListResponse = DocListResponse <string> .FromJsonToStringList(allDocsJsonString); return(docListResponse); }
/// <summary> /// Returns a JSON structure of all of the documents in a given database. /// The information is returned as a JSON structure containing meta information /// about the return structure, including a list of all documents and basic contents, /// consisting the ID, revision and key. The key is the from the document’s _id. /// </summary> /// <param name="queryParams">Instance of <see cref="ListQueryParams"/> to be used for filtering.</param> /// <returns><see cref="DocListResponse{STRING}"/> containing list of JSON strings.</returns> /// <exception cref="CouchDBClientException">Error response received from CouchDB server.</exception> /// <exception cref="InvalidOperationException">Malformed JSON string received from CouchDB server..</exception> public async Task <DocListResponse <string> > GetAllStringDocumentsAsync(ListQueryParams queryParams = null) { if (queryParams == null) { queryParams = new ListQueryParams(); } var allDocsUrl = QueryParams.AppendQueryParams("_all_docs", queryParams); var response = await _handler.SendRequestAsync(allDocsUrl, RequestMethod.GET, Request.Empty).Safe(); if (response == null) { return(null); } var allDocsJsonString = await response.ReadAsStringAsync(false).Safe(); var docListResponse = DocListResponse <string> .FromJsonToStringList(allDocsJsonString); return(docListResponse); }