wixData.query beforeInsert() OR wixData.insert afterQuery()

Can anyone guide me through the implementation of either wixData.query beforeInsert() OR wixData.insert afterQuery() ?

Thank you in advance!!

you need to create data.js file under your backend folder and put your function there
https://www.wix.com/corvid/reference/wix-data.Hooks.html#beforeInsert