1
0
mirror of https://github.com/franjsco/umbrello-api synced 2024-12-21 21:14:07 +01:00
This commit is contained in:
Francesco Esposito 2019-08-22 17:43:56 +02:00
parent 0dc4a2924f
commit eb6f2066df

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;