Kitura-CouchDB
Kitura-CouchDB copied to clipboard
Improve documentation for queryByView with decodeDocuments
https://github.com/IBM-Swift/Kitura-CouchDB/pull/97 introduced the decodeDocuments
helper function, and adds comments that elude to the fact that when querying documents from CouchDB, you must set the include_docs
parameter to true
for Couch to include the documents themselves in the response. However, the existing queryByView
function does not document this requirement, and so it could be confusing that something like this does not work:
database.queryByView("fruitView", ofDesign: "fruitDesign", usingParameters: []) {
(documents, error) in
let fruitDocs = documents?.decodeDocuments(ofType: Fruit.self)
....
}
The solution in this case is to add usingParameters: [.includeDocs(true)]
. I feel this use-case should be discussed in the documentation for the queryByView function.
@djones6 thank you very much. I almost lost a hour to digging why decodeDocuments
return empty array even for simple sample