1
votes

I am using PouchDB/CouchDB for my hybrid ionic mobile app. Now i want to implement audit trail for the same. This link Versioning using storing versions as attachment in the same document suggests to store versions of the document as attachment of the same document. I have few queries regarding this:

Q1: Is the approach specific to jquery.couch.js as when i try to implement in my mobile app as: in couchdb i have a doc(say _id=1) having its versions as attachments. Now when i sync this doc on my mobile device (using pouch sync), i fetch the doc without its attachments(its versions), then modify this document and in attachment i add the previous revision and then sync.. Now since its revision no is greatest, it goes in couchdb and this latest document (_id=1) has attachment which only shows latest version...

When i do sync from couchdb to pouchdb, do i need to fetch this doc(_id=1)with its attachments (which contains all revisions)? If yes, then in this case i will be syncing these attachments unnecessarily which will be overhead.... Then in this case should i go with storing versions in separate document apparoach?

1
your first link is brokenTimoSolo

1 Answers

1
votes

couch/pouch already keeps an audit log of changes in the revisions. You can access the changes using the _changes endpoint and display it when needed. (storing it as an attachment seems to be duplicating the existing data)

Pouch: https://pouchdb.com/api.html#changes

Couch: http://docs.couchdb.org/en/2.0.0/api/database/changes.html