Skip to content

Sync failed for updated docs from a local encrypted db #42

Description

@AndreasHohnholt

Hi,

if I update a doc and then try to sync this doc to a remote db - pouchdb throw this exception:
Error: There was a problem getting docs.
at finishBatch (pouchdb-6.1.1.js:13009)

If I create a new doc in an empty db (local and remote) the first sync works well.

Here is the code of my crypto transform (I am using sjcl because it works well on iOS Safari) :

localDB.transform({
            incoming: function (doc) {
              Object.keys(doc).forEach(function (field) {
                if (field !== '_id' && field !== '_rev' && field !== '_revisions' && field !== '_attachments') {
                    var password = appuser.GetDBPassword();
                    var fieldValue = sjcl.encrypt(password,angular.toJson(doc[field]));
                    doc[field] = fieldValue;
                }
              });
              return doc;
            },
            outgoing: function (doc) {
              Object.keys(doc).forEach(function (field) {
                if (field !== '_id' && field !== '_rev' && field !== '_revisions' && field !== '_attachments') {
                  var password = appuser.GetDBPassword();
                  var fieldValue = angular.fromJson(sjcl.decrypt(password,doc[field]));
                  doc[field] = fieldValue;
                }
              });
              return doc;
            }
        });  

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions