PouchDb通过蓝牙复制文档

时间:2022-08-13 22:50:57

I have two pouch databases on two mobiles phones A and B. I have a document on A and I want to replicate it to B, of course I can't use the classic replication API because I'm on a bluetooth network.

我在两部手机A和B上有两个数据库。我有一个关于A的文档,我想将它复制到B,当然我不能使用经典的复制API,因为我在蓝牙网络上。

So I get the document on A:

所以我在A上得到了文件:

_id: 'myDocument'
_rev: '1-651b13c02859d5b90a6043193e7bc078'
content: {...}

And I send it over bluetooth to B.

我通过蓝牙发送给B.

When I put the document on B I have a conflict error, except if I set the document _rev to null. I'd like to create the document on B exactly like A, with same revision, how to do it ?

当我将文档放在B上时,我有一个冲突错误,除非我将文档_rev设置为null。我想在B上创建与A完全相同的文档,使用相同的版本,怎么做?

1 个解决方案

#1


2  

This can be accomplished with pouchdb-replication-stream and related tools like pouchdb-load. These tools allow you to dump a PouchDB database to a string, and then load that string into another PouchDB database. Since it's just a string, you can send it over Bluetooth or whatever transfer protocol you like.

这可以通过pouchdb-replication-stream和相关工具(如pouchdb-load)来完成。这些工具允许您将PouchDB数据库转储到字符串,然后将该字符串加载到另一个PouchDB数据库中。由于它只是一个字符串,您可以通过蓝牙或您喜欢的任何传输协议发送它。

#1


2  

This can be accomplished with pouchdb-replication-stream and related tools like pouchdb-load. These tools allow you to dump a PouchDB database to a string, and then load that string into another PouchDB database. Since it's just a string, you can send it over Bluetooth or whatever transfer protocol you like.

这可以通过pouchdb-replication-stream和相关工具(如pouchdb-load)来完成。这些工具允许您将PouchDB数据库转储到字符串,然后将该字符串加载到另一个PouchDB数据库中。由于它只是一个字符串,您可以通过蓝牙或您喜欢的任何传输协议发送它。