started to modify code in test.js to save random events to the database