updated index.js to take in the objects from the database