This commit is contained in:
Francesco Esposito 2019-08-22 17:43:56 +02:00
parent 0dc4a2924f
commit eb6f2066df
1 changed files with 26 additions and 0 deletions

26
src/db/index.js Normal file
View File

@ -0,0 +1,26 @@
import mongoose from 'mongoose';
import citySchema from './city.model';
import logger from '../logger';
import config from '../config';
const options = {
useNewUrlParser: true,
user: config.database.user,
pass: config.database.password,
};
mongoose.connect(config.database.host, options);
mongoose.set('useFindAndModify', false);
const db = mongoose.connection;
db.on('error', (err) => logger.error(err));
db.once('open', () => logger.info('Database connected'));
export default citySchema;