解决小袋沙发数据库 [英] Resolve Pouch Couch DB

查看:76
本文介绍了解决小袋沙发数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个脱机工作的原型网站,该网站利用Pouch DB使其在线时同步回服务器上的CouchDB。

I am developing a prototype website that works offline that utilises Pouch DB so that it syncs back up to a CouchDB on a server when it goes online.

a href = http://pouchdb.com/guides/conflicts.html rel = nofollow noreferrer> Pouch DB冲突指南说:

The Pouch DB conflicts guide says:


要解决冲突,您可以在当前获胜者的上方简单放置put()一个新修订。

To resolve the conflict, you simpy put() a new revision on top of the current winner.

你怎么做到这一点?我尝试了以下功能,但均未达到预期的效果:

How do you do this? I have the tried the following functions but neither work as expected:

function (current, chosen) {
    chosen._rev = current._rev;
    chosen._conflicts = [];
    db.put(chosen);
};

function (chosen) {;
    db.put(chosen);
};

顶部函数需要两个文档:

The top function takes two documents:


  • 当前赢家的文件

  • 用户选择成为新赢家的文件。

我已经在某些地方阅读过(在这里)删除丢失的冲突是必要的,但我宁愿不删除任何可能的东西,并且Pouch DB指南对此也没有提及。

I've read in some places (like here) that deleting the losing conflicts is necessary but I would rather not delete anything if possible, and the Pouch DB guide has no mention of this.

推荐答案

您是对的;您需要删除失败的冲突(听起来很不愉快)。编写指南时,我犯了一个错误。

You're right; you need to delete the losing conflicts (as unsavory as that sounds). I made a mistake when I wrote the guide; the conflicts will still exist unless you delete them.

顺便说一句,删除冲突的修订仅意味着在它们之上添加一个墓碑。因此,除非您明确压缩数据库,否则实际上不会删除任何内容。 PouchDB和CouchDB都是这种情况。

By the way, deleting the conflicting revisions just means adding a "tombstone" on top of them. So really nothing is being "deleted" unless you explicitly compact your database. This is the case with both PouchDB and CouchDB.

编辑:我修复了文档。 无论如何,您是否可以更新指南以反映您需要删除任何不需要的冲突版本的事实?我们喜欢请求请求,特别是那些直接处理此类请求的人! :)需要修改的文档是这一个

I fixed the docs. In any case, could you please update the guide to reflect that fact that you need to delete any unwanted conflicting revisions? We love pull requests, especially from folks who have dealt with this kind of stuff first-hand! :) The document that needs to be modified is this one.

这篇关于解决小袋沙发数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆