Hi,
I found a bug were after hooks affect the original item. That should not happen according to the doc
Because the afterUpdate hook is called after the update() is executed, it cannot affect the item that is being updated in the collection. It can only affect the item returned by update() .
but as you can see in the video here . It does⦠badly.
here is the data code for data.js
import wixData from 'wix-data';
let options = {
"suppressAuth": true,
"suppressHooks": true
};
export function Projects_afterInsert(item, context) {
item.originalId = item._id;
delete item._id;
return wixData.insert('copy', item, options);
}
export function Projects_afterUpdate(item, context) {
return wixData.query('copy').eq('originalId', item._id).find().then(result => {
item._id = result.items[0]._id;
return wixData.update('copy', item, options);
});
}
Demo website
-
Could you confirm that behaviour is a bug?
-
If itβs, do you plan on fixing this soon?
Thx, @Sheyla Ruiz, @Yisrael (Wix)
#bug, #wixData