Pouchdb: get allDocs without design view

Created on 2 Mar 2016  路  4Comments  路  Source: pouchdb/pouchdb

Hi

im write a query to retrive all record on couchdb with

mydb.allDocs({include_docs: true, attachments: true, startkey: '_design\uffff' }).then(function(doc) { q.resolve(doc); }).catch(function (err) { q.reject(err); });

but i get always an empty result (i have 4 records).
is there a solution to retrive all docs without design documents?

Most helpful comment

Hi, so the doc here is not correct when talking about filtering out design documents in allDocs with {startkey: '_design0'} https://pouchdb.com/2014/05/01/secondary-indexes-have-landed-in-pouchdb.html.
I tried what @enzoaeneas suggested and it worked better :)

But I didn't succeed to do the same with descending: true ...

As design documents are everywhere and the usage of allDocs with cleverly chosen _id is often advised for simple use cases, it would be great to have an obvious option to get the design documents if needed, and not having them by default (or the contrary to avoid modifying the current behavior).

All 4 comments

Your query looks correct to me. I'd check the Network tab to make sure that it's sending the right request to CouchDB and that you really do have 4 documents that are not design docs.

Also a protip: you can use q.when() instead of wrapping PouchDB promises yourself; there is a good writeup in this blog post: http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html

Let me know if that solves your issue! Closing for now; please reopen if necessary.

@nolanlawson it does not work with descending.

if I use guids as my _id, it will not work either. I had to use:
{ 'include_docs': true, 'endkey': '_design', 'options.inclusive_end': false }

Hi, so the doc here is not correct when talking about filtering out design documents in allDocs with {startkey: '_design0'} https://pouchdb.com/2014/05/01/secondary-indexes-have-landed-in-pouchdb.html.
I tried what @enzoaeneas suggested and it worked better :)

But I didn't succeed to do the same with descending: true ...

As design documents are everywhere and the usage of allDocs with cleverly chosen _id is often advised for simple use cases, it would be great to have an obvious option to get the design documents if needed, and not having them by default (or the contrary to avoid modifying the current behavior).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ddolheguy picture ddolheguy  路  6Comments

daleharvey picture daleharvey  路  4Comments

Kentoseth picture Kentoseth  路  6Comments

BrainBuzzer picture BrainBuzzer  路  3Comments

virtualit786 picture virtualit786  路  5Comments