If you are trying to connect directly to a database from a web client. you're effectively re-creating the sort of webapps that cause the SQL Slammer worm to trash major Internet applications years ago.
Don't connect directly to a database from an Internet client
If you are trying to connect to a database from a webserver such as NodeJS, then the best bet is to use an API library. To the best of my (limited) knowledge, there's no universal database interface like
JDBC for JavaScript on any JavaScript framework.
So we'd need to know what you are trying before we can give any advice.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.