Sign in
Log inSign up
Abdulhakeem Mustapha

1 like

6 comments

Mardone Dias
Mardone Dias
Jul 15, 2020

Hello,

I have a little problem with couchdb, it's about pagination with startkey, endkey and limit. I can page to the next pages. But, I cannot understand how to keep the previous key to return. I use nodejs + express. If I could pass on some material with an example I would appreciate it. I've looked for a lot, a lot, but, there is nothing but the algorithm of the documentation itself. If you can help me I would appreciate it very much.

Thank you.

1
·
·5 replies
Abdulhakeem Mustapha
Abdulhakeem Mustapha
Author
·Jul 16, 2020

Sure. I might need more context though

·
Mardone Dias
Mardone Dias
Jul 16, 2020

Abdulhakeem Mustapha

Hello,

The problem was creating the page back, but, I got a tip on how to get around. I use VueJs on the frontend and NodeJs + express on the backend. I haven't implemented it yet, but the solution basically consists of storing a list of startkeys in localstorage, so for each page that goes forward I will have the startkey for the link to come back.

Thank you for your attention.

·
Abdulhakeem Mustapha
Abdulhakeem Mustapha
Author
·Jul 16, 2020

Mardone Dias

If it's about pagination, why not use limit&skip rather than start & end key? Do you have any special use case why you have to use keys?

1
·
Mardone Dias
Mardone Dias
Jul 16, 2020

Abdulhakeem Mustapha

Hello,

The documentation says that limit & skip performs poorly with a large amount of data. So I already want to avoid this problem in the future, treating it as efficiently as possible.

My question was how to return to the previous page. And the solution that stores the keys in the frontend will not add complexity to the project.

I appreciate the suggestion, I will do a deeper analysis to see the cost benefit.

Thank you.

·
Abdulhakeem Mustapha
Abdulhakeem Mustapha
Author
·Jul 16, 2020

Mardone Dias

I see. Personally in my experience, I've not hit those performance bottlenecks yet (I've used CouchDB to handle a few thousands of documents). And I'd say, it's quite harder fetching by keys.

However, if that's the case, a workaround could be running an _all_docs to get a list of all documents (just rev and id, without the full document), save those in state/localstorage and use that as basis for performing queries using the ids for start & end key.

1
·