Pouchdb. How to verify a doc is replicated

时光毁灭记忆、已成空白 提交于 2019-12-24 17:14:18

问题


Im using poychdb basically to let a mobile user create sales orders offline, then later replicate them to central couchdb server, then process them there on a cron job basis.

As replication can sync some docs...then stop (lost Internet. ..) i need a way to block the mobile user from editing those already synced orders. But hd can still edit other non-yet-uploaded orders

There is some way to do that?


回答1:


The replicate() function returns an event emitter which emits a 'change' event: http://pouchdb.com/api.html#replication.

So you can listen for 'change' events, which will tell you how many documents were written and the seq (update sequence #) of the last written document. Using the changes feed and the since parameter, you can figure out which documents were already written to the remote database.

E.g. if the last_seq is 50, then changes({since: 50}) will give you all documents that haven't been synced yet.



来源:https://stackoverflow.com/questions/24899938/pouchdb-how-to-verify-a-doc-is-replicated

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