File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
src/server/database/storage Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ module.exports = async () => {
6060 const mdb = await collection ( DISCUSS_DB_COMMENT )
6161 const cdb = await collection ( DISCUSS_DB_COUNTER )
6262
63- return {
63+ const databaseFn = {
6464 async addAdmin ( data ) {
6565 await adb . add ( data )
6666 } ,
@@ -85,7 +85,7 @@ module.exports = async () => {
8585 } ,
8686 async addComment ( data ) {
8787 const res = await mdb . add ( data )
88- return [ await this . getCommentByID ( res . id ) ]
88+ return [ await databaseFn . getCommentByID ( res . id ) ]
8989 } ,
9090 async deleteComment ( id ) {
9191 await mdb . doc ( id ) . delete ( )
@@ -142,6 +142,7 @@ module.exports = async () => {
142142 return idHandler ( res . data ) [ 0 ]
143143 }
144144 }
145+ return databaseFn
145146 } catch ( error ) {
146147 // eslint-disable-next-line no-console
147148 console . error ( error )
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ module.exports = async () => {
3434 try {
3535 await connectDatabase ( )
3636
37- return {
37+ const databaseFn = {
3838 async addAdmin ( data ) {
3939 await db . collection ( DISCUSS_DB_ADMIN ) . insertOne ( data )
4040 } ,
@@ -59,7 +59,7 @@ module.exports = async () => {
5959 } ,
6060 async addComment ( data ) {
6161 const res = await db . collection ( DISCUSS_DB_COMMENT ) . insertOne ( data )
62- return [ await this . getCommentByID ( res . insertedId . toString ( ) ) ]
62+ return [ await databaseFn . getCommentByID ( res . insertedId . toString ( ) ) ]
6363 } ,
6464 async deleteComment ( id ) {
6565 await db . collection ( DISCUSS_DB_COMMENT ) . deleteOne ( { _id : ObjectId ( id ) } )
@@ -119,6 +119,7 @@ module.exports = async () => {
119119 return idHandler ( [ res ] ) [ 0 ]
120120 }
121121 }
122+ return databaseFn
122123 } catch ( error ) {
123124 // eslint-disable-next-line no-console
124125 console . error ( error )
You can’t perform that action at this time.
0 commit comments