TypeError: connection.connect is not a function

Today, when I wrote node.js to operate the database, I encountered a typeerror: connection.connect is not a function when setting up the database connection. The following is the bug prompt, as shown in the figure

when I found this error, I immediately went to connection.connect, but I didn’t find anything wrong,
For this reason, I made a special effort to find the previous code and compare it. The following is the thinking at that time

later, I asked my friend to check the custom module
PS: after staring at it for more than ten minutes, I didn’t find the error. At this moment, I felt like a mentally retarded person

later, I had to check one by one, I found that my mistake was to write the return value of the function as an object….. Verification complete….. Retarded stone hammer…..

Change it to the following way

rerun

Read More: