Adapted the code so I could read and write out the content of the database collection