问题
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