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