database.js 753 B

12345678910111213141516171819202122
  1. var mongoose = require('mongoose');
  2. var start = function() {
  3. return new Promise((resolve, reject) => {
  4. //Set up default mongoose connection
  5. var mongoDB = 'mongodb://127.0.0.1/kairoscope_dev';
  6. mongoose.connect(mongoDB, {useNewUrlParser: true, useUnifiedTopology: true}).then(
  7. () => {
  8. /** ready to use. The `mongoose.connect()` promise resolves to mongoose instance. */
  9. console.log("Database connected");
  10. resolve();
  11. },
  12. err => {
  13. /** handle initial connection error */
  14. console.log("Error connecting to database");
  15. reject(err);
  16. }
  17. );
  18. });
  19. }
  20. module.exports.start = start;