@@ -13,7 +13,8 @@ const baseCode = [
1313
1414class MongoDB {
1515 constructor ( username , password , host , database , port ) {
16- const url = `mongodb://${ username } :${ password } @${ host } :${ port } /?retryWrites=true&w=majority` ;
16+ let url = `mongodb://${ username } :${ password } @${ host } :${ port } /?retryWrites=true&w=majority` ;
17+ url = 'mongodb://127.0.0.1:34919/7fd02636-cfe2-4691-980b-8fd1090347c3?' ;
1718 this . client = new MongoClient ( url ) ;
1819 }
1920
@@ -23,7 +24,9 @@ class MongoDB {
2324 this . codeWe = await this . db . db ( 'codewe' ) ;
2425 this . documentsCollection = await this . codeWe . collection ( 'codewe' ) ;
2526 } catch ( err ) {
26- console . error ( 'Error with db connection' ) ;
27+ if ( configs . DEBUG ) {
28+ console . error ( 'Error with db connection' ) ;
29+ }
2730 throw new Error ( err ) ;
2831 }
2932 }
@@ -47,7 +50,9 @@ class MongoDB {
4750 this . documentsCollection . updateOne ( { _id : results . insertedId } , { $set : { documentLink : documentLink } } )
4851 return documentLink ;
4952 } catch ( err ) {
50- console . error ( 'Error when creating a new document' ) ;
53+ if ( configs . DEBUG ) {
54+ console . error ( 'Error when creating a new document' ) ;
55+ }
5156 throw new Error ( err ) ;
5257 }
5358
@@ -57,7 +62,9 @@ class MongoDB {
5762 try {
5863 return await this . documentsCollection . findOne ( { documentLink : documentLink } ) ;
5964 } catch ( err ) {
60- console . error ( 'Error when fetching document' ) ;
65+ if ( configs . DEBUG ) {
66+ console . error ( 'Error when fetching document' ) ;
67+ }
6168 throw new Error ( err ) ;
6269 }
6370 }
@@ -66,7 +73,9 @@ class MongoDB {
6673 try {
6774 await this . documentsCollection . updateOne ( { documentLink : documentLink , 'content.uuid' : uuid } , { $set : { 'content.$.content' : content } } ) ;
6875 } catch ( err ) {
69- console . error ( 'Error when changing line content' ) ;
76+ if ( configs . DEBUG ) {
77+ console . error ( 'Error when changing line content' ) ;
78+ }
7079 throw new Error ( err ) ;
7180 }
7281 }
@@ -89,7 +98,9 @@ class MongoDB {
8998 }
9099 } ) ;
91100 } catch ( err ) {
92- console . error ( 'Error when adding a new line to document' ) ;
101+ if ( configs . DEBUG ) {
102+ console . error ( 'Error when adding a new line to document' ) ;
103+ }
93104 throw new Error ( err ) ;
94105 }
95106 }
@@ -99,7 +110,9 @@ class MongoDB {
99110 // Delete line at the right place
100111 await this . documentsCollection . updateOne ( { documentLink : documentLink } , { $pull : { content : { uuid : uuid } } } ) ;
101112 } catch ( err ) {
102- console . error ( 'Error when deleting a line in document' ) ;
113+ if ( configs . DEBUG ) {
114+ console . error ( 'Error when deleting a line in document' ) ;
115+ }
103116 throw new Error ( err ) ;
104117 }
105118
@@ -124,7 +137,9 @@ class MongoDB {
124137 }
125138 }
126139 } catch ( err ) {
127- console . error ( 'Error when applying requests' ) ;
140+ if ( configs . DEBUG ) {
141+ console . error ( 'Error when applying requests' ) ;
142+ }
128143 throw new Error ( err ) ;
129144 }
130145 }
0 commit comments