refactor db connection and error handling to Dao.js, also log errors