db.js 532 B

1234567891011121314151617
  1. const mongoose = require('mongoose');
  2. const config = require('../config/config.json');
  3. const db = config.url;
  4. //var db = 'mongodb://database_preprod:27017/mean-fatboar-db';
  5. var mongoURI = 'mongodb://localhost:27017/my-db';
  6. mongoose.set('useCreateIndex', true)
  7. mongoose.connect(db, {useNewUrlParser: true, useUnifiedTopology: true })
  8. .then(() => {
  9. console.log("Successfully connected to the database.");
  10. }).catch(err => {
  11. console.log("Could not connect to the database.", err);
  12. });
  13. module.exports = mongoose.connection;