Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PouchDb alldocs() with a query

Tags:

pouchdb

I've been reading on how to query large collections. In my case I have over 9000 documents in the database. They can be filtered in the UI of course, but at start all 9000 are browse-able with pagination.

I can fetch all of them with allDocs without params, but once I start filtering I'll be querying. But how should I go about it then ?

query - find - alldocs ?

and if alldocs, can you sent mango queries to that ? I know you can filter on keys, but I'll be filtering on fields in the docs.

Can anyone give me a clear example if you can use alldocs with use of a filter not on the keys but on fields ?

like image 516
kenny Avatar asked Oct 29 '25 07:10

kenny


1 Answers

In short, no. AllDocs is useful when you are selecting based on the document ID and using startkey and endkey options. If you wish to select documents based on something other than the ID then allDocs is not going to work efficiently for you.

For queries based on document field values you should use map/reduce queries or PouchDB find (Mango queries). There are some good examples and documentation on the PouchDb site. Mango queries are considered easier to work with but both approaches are perfectly valid.

like image 73
IanC Avatar answered Oct 31 '25 11:10

IanC