Pouchdb。如何验证文档是否已复制

编程入门 行业动态 更新时间:2024-10-26 14:35:13
本文介绍了Pouchdb。如何验证文档是否已复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我基本上是使用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。如何验证文档是否已复制

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

发布评论

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

>www.elefans.com

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