It is said that no-sql databases like MongoDB fits best with NodeJS with a great wrapper package Mongoose. But there are also many good drivers exists for SQL support with NodeJS, so what are the factors due to which SQL is not considered to be used with NodeJS?
Blaine Garrett
Software Engineer and Artist
The major thing I think is the early adopters of Nodejs used it with document based Database and it grew as a stack together. I recently started using postgres with nodejs using node-postgres which I found to have a very good mongoose (ORM) equivalent in Sequelize.
Nodejs will work with any sql based database just in the same way it relates with its document based database.
Personally, I have no reason to believe it should matter. There might be something with Node's single threading that prefers NoSQL that I am not thinking of.
However, I really think you need an ORM to enforce type consistency at the code level regardless of which type of DB you use. When I was working in the LAMP stack ages ago this was an issue - i.e. some new fields are introduced that are not supported by the schema, etc and then things blow up at the query level. This is rigid but at least there is some sort of type enforcement.
In regard to NoSQL - having worked with Google's Cloud Datastore since the early days of AppEngine, Google offered builtin packages (db and later ndb) which functioned as an ORM. Honestly, it wasn't until years later I realized you could bypass the ORM layer. Then I started working with Firestore which didn't have a builtin ORM and we had a lot of issues with data consistency. These document based databases can be used as proper databases, but without an ORM, they're sorta just log dumps.
I've heard great things about Sequelize and like the idea that it is a db-agnostic interface similar to Jooq in Java.
Keep in mind data migrations as well. This is important for any type of DB. Flyway was a great Java tool for managing revisions of schema, fixture data, and migrations. I'm sure there is a similar tool for node.