pouchdb-community/transform-pouch

incoming not running on PUT with masked _id

Closed this issue · 1 comments

I want to mask the _id with another fieldname.

When I add the following test, it does not work. The incoming-function will not fire. isUntransformable is false and I see no way why this should not work.

    it('transforms on PUT, with masked _id', function () {
      db.transform({
        incoming: function (doc) {
          doc._id = doc.passportId;
          delete doc.passportId;
          return doc;
        }
      });
      return db.put({passportId: 'foo'}).then(function () {
        return db.get('foo');
      }).then(function (doc) {
        doc._id.should.equal('foo');
      });
    });

When I use bulkDocs instead of put, it works as expected.

    it('transforms on bulkDocs, with masked _id', function () {
      db.transform({
        incoming: function (doc) {
          doc._id = doc.passportId;
          delete doc.passportId;
          return doc;
        }
      });
      return db.bulkDocs([{passportId: 'foo'}]).then(function () {
        return db.get('foo');
      }).then(function (doc) {
        doc._id.should.equal('foo');
      });
    });

Is this behavior intended?

Hi @pubkey, this issue with incoming() not running on put() to remote databases has been noticed by a few people and we believe it is fixed in master and the newly released v2.0.0. Would you be able to check whether this issue is now resolved?