incoming not running on PUT with masked _id
Closed this issue · 1 comments
pubkey commented
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?