Is there a way to get all revisions of a document in PouchDB when using the change feed?

廉价感情. 提交于 2019-12-01 12:55:02
Mathijs

With some help of macrog I've found a way to do what I wanted to do. Short summary I wanted a way to get all revisions of my documents, including the ones which had been removed. This is what I use now:

db.get(String(id), {
    revs: true, 
    open_revs: 'all' // this allows me to also get the removed "docs"
  }).then(function(found) {
    console.log(found);
  });

Granted I no loger use db.changes() to get all the revisions of a document. But at least I'm able to do what I wanted to do.

Try one of the options - this it's from pouchdb docs:

db.get(docId, [options], [callback])

Retrieves a document, specified by docId.

Options All options default to false unless otherwise specified.

options.rev: Fetch specific revision of a document. Defaults to winning revision (see the CouchDB guide).

options.revs: Include revision history of the document.

options.revs_info: Include a list of revisions of the document, and their availability.

options.open_revs: Fetch all leaf revisions if open_revs="all" or fetch all leaf revisions specified in open_revs array. Leaves will be returned in the same order as specified in input array.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!