使用更改提要时,是否有办法在PouchDB中获取文档的所有修订版本?

编程入门 行业动态 更新时间:2024-10-12 12:30:25
本文介绍了使用更改提要时,是否有办法在PouchDB中获取文档的所有修订版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此刻,我正在摆弄PouchDB。我将其用作在本地存储数据而不将其链接到CouchDB的一种方式。我一直在尝试为单个文档创建一个还原/撤消方法。为此,我想使用 doc的先前版本。在阅读PouchDB文档时,我遇到了更改提要,这乍一看似乎是获得所有文档的所有修订的一种方式。但是,在尝试获取文档的所有修订后,我仅获得了最新修订。我尝试了以下操作来进行更改:

I'm fiddling around with PouchDB at the moment. I use it as a way to store data locally without it being linked to CouchDB. What I've been trying to do is to create a revert/undo method for a single doc. For this I would like to use the previous revisions of the "doc". I came across the changes feed while reading the PouchDB documentation, which at first seems to be a way to get all the revisions of the all the "docs". However, after trying to get all the revisions of the "docs" I've only got the latest revision. I've tried the following to get the changes:

db.changes({ since: 0, style: 'all_docs', include_docs: true // eslint-disable-line camelcase }).then(function(results) { console.log(results); });

TL; DR如何获取(一个或多个)文档的所有修订PouchDB?

TL;DR how can I get all the revisions of a (or all) document(s) in PouchDB?

推荐答案

在 macrog 我找到了一种可以做自己想做的方法。简短摘要我想要一种方法来获取我的文档的所有修订版,包括已删除的文档。这就是我现在使用的:

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); });

我没有日志记录器,请使用db.changes()获取文档的所有修订版。但至少我能做我想做的事。

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.

更多推荐

使用更改提要时,是否有办法在PouchDB中获取文档的所有修订版本?

本文发布于:2023-10-30 04:34:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541784.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:提要   版本   办法   文档   PouchDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!