我基本上是使用poychdb来让移动用户离线创建销售订单,然后将它们复制到中央Couchdb服务器,然后在Cron作业的基础上在那里处理它们。
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.
由于复制可以同步某些文档...然后停止(丢失Internet ...),我需要一种方法来阻止移动用户编辑那些已同步的订单。但是hd仍然可以编辑其他尚未上传的订单
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
有某种方法吗?
推荐答案replicate()函数返回一个事件发射器,该事件发射器发出'change'事件: pouchdb/api.html#replication 。
The replicate() function returns an event emitter which emits a 'change' event: pouchdb/api.html#replication.
因此您可以收听'change'事件,该事件将告诉您写入了多少文档以及 seq (更新序列号)。使用更改feed和 since 参数,您可以确定哪些文档已被写入远程数据库。
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.
例如如果 last_seq 是50,则 changes({since:50})将为您提供所有未已同步。
E.g. if the last_seq is 50, then changes({since: 50}) will give you all documents that haven't been synced yet.
更多推荐
Pouchdb。如何验证文档是否已复制
发布评论