Obtaining the list of document revisions in PouchDB when Upsert plugin is used

238 Views Asked by At

I am building an ElectronJS app and storing a list of documents locally using PouchDB. I am using the pouchdb-upsert for inserting new records. It is also creating revisions in the database and I can see them nicely.

PouchDB data screen capture

Problem is that I cannot fetch a specific revision using db.get or a batch of them using db.bulkGet following PouchDB's documentation. In both cases I get a 404 error from the database.

I need to be able to obtain the list of revisions as PouchDB documents so users be able to maintain a history of their documents as they edit them or fork a revision as a new document when needed. Similar to the google docs history feature. How can I obtain the list of revisions created by the upsert plugin?

1

There are 1 best solutions below

0
Megidd On

You can use some options while fetching a document to get a list of all revisions:

db.get(docId, [options], [callback])
...
options.revs: Include revision history of the document.
...

Also take a look at this related answer.