mirror of
https://github.com/franjsco/umbrello-api
synced 2024-12-10 16:07:36 +01:00
Add db
This commit is contained in:
parent
0dc4a2924f
commit
eb6f2066df
26
src/db/index.js
Normal file
26
src/db/index.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user