File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 11import mongoose from 'mongoose' ;
22
3- const uri = `mongodb://${ process . env . DATABASE_USERNAME } :${ process . env . DATABASE_PASSWORD } @${ process . env . DATABASE_HOSTNAME } /${ process . env . DATABASE_DATABASE } ` ;
3+ const uri = `mongodb://${ process . env . DATABASE_USERNAME } 1 :${ process . env . DATABASE_PASSWORD } @${ process . env . DATABASE_HOSTNAME } /${ process . env . DATABASE_DATABASE } ` ;
44
55class Database {
66 constructor ( ) {
77 this . init ( ) ;
88 }
99
1010 init ( ) {
11- mongoose . connect ( uri , {
12- useNewUrlParser : true ,
13- useUnifiedTopology : true ,
14- } ) ;
11+ mongoose
12+ . connect ( uri , {
13+ useNewUrlParser : true ,
14+ useUnifiedTopology : true ,
15+ } )
16+ . then ( ( ) => {
17+ console . info ( 'Database connection successfully' ) ;
18+ } )
19+ . catch ( ( err ) => {
20+ console . error ( 'Database connection fail' ) ;
21+ console . error ( err ) ;
22+ } ) ;
1523 }
1624}
1725
You can’t perform that action at this time.
0 commit comments