Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for queryByView with decodeDocuments #107

Open
djones6 opened this issue Aug 21, 2019 · 1 comment
Open

Improve documentation for queryByView with decodeDocuments #107

djones6 opened this issue Aug 21, 2019 · 1 comment

Comments

@djones6
Copy link
Contributor

djones6 commented Aug 21, 2019

#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.

@MadGeorge
Copy link

@djones6 thank you very much. I almost lost a hour to digging why decodeDocuments return empty array even for simple sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants