My scenario:
I have a collection called ‘Shows’ with a primary field of show_id. I want to update the show_id to be the same as the _id for the record.
Codebehind file:
import wixData from ‘wix-data’;
export function Shows_afterInsert(item) {
const options = {
“suppressAuth”: true ,
“suppressHooks”: true ,
};
const { _id } = item;
wixData.get(‘Shows’, _id)
.then((show) => {
show.show_id = _id;
wixData.update(‘Shows’, show, options);
}). catch ((err) => {
console.error(Error occured **while** updating the collection: ${err}
)
})
}
Any help solving this is greatly appreciated.
Thanks!