code for saving date and categories it falls into everytime a doument is saved or updated