1+ require ( 'dotenv' ) . config ( ) ;
2+
13// INSERT URI TO MONGODB TO SET UP USER DATABASE
2- const MONGO_URI = 'mongodb+srv://seconddbtest:seconddbtest@cluster0.yhztme0.mongodb.net/?retryWrites=true&w=majority' ;
3- const mongoose = require ( 'mongoose' )
4+ const MONGO_URI = process . env . USER_DB_URI ;
5+ console . log ( MONGO_URI ) ;
6+ // const MONGO_URI = process.env.CHRONOS_USER_DB_URI;
7+ const mongoose = require ( 'mongoose' ) ;
48
5- const db2 = mongoose . createConnection ( MONGO_URI )
6- // .then(() => {
7- // console.log('Connected to User database...');
8- // })
9- // .catch(err => {
10- // console.log('Error connecting to User database: ', err);
11- // })
9+ const userDB = mongoose . createConnection ( MONGO_URI ) ;
10+ // .then(() => {
11+ // console.log('Connected to User database...');
12+ // })
13+ // .catch(err => {
14+ // console.log('Error connecting to User database: ', err);
15+ // });
1216// console.log('establishing connection to database');
1317
14-
1518const userSchema = new mongoose . Schema ( {
16- username : { type : String , required :true , unique : true } ,
17- password : { type : String , required :true } ,
18- email : String ,
19- services : [ ] ,
20- mode : { type : String , default : 'light' }
19+ username : { type : String , required : true , unique : true } ,
20+ password : { type : String , required : true } ,
21+ email : String ,
22+ services : [ ] ,
23+ mode : { type : String , default : 'light' } ,
2124} ) ;
2225
23- const UserModel = db2 . model ( 'users' , userSchema ) ;
24- module . exports = UserModel ;
26+ const UserModel = userDB . model ( 'users' , userSchema ) ;
27+ module . exports = UserModel ;
0 commit comments