The TodoMVC++ application will be using the PostgreSQL relational database for storing data and the promised-based Sequelize for the object-relationship mapping. After introducing these tools, Kevin talks about the advantages of using SQL over NoSQL databases like Mongoose.
- We've got two more big media sections here this afternoon before I turn you loose. The first is digging into the data tier of the application that we've been looking at today. And in this case, we're actually gonna be looking at how to use Node.js with a relational database. Anyway, so the stack we're gonna look at is one that's actually less heralded in Node just because most of the NoSQL databases out there are, because they natively speak JSON, they end up being a really good fit for Node.js.
So if you're gonna be using a relational database of any kind with Node.JS, the chances are you're probably gonna go one of two routes. You're gonna either use a driver for your database directly, so just use PG or Postgres or a MySQL driver directly, maybe execute raw SQL against it or maybe use a SQL builder. But if you're using an RM in Node.js, you're probably gonna use Sequelize. Sequelize is definitely the most feature-rich ORM that's out there for Node.js today so if you're looking for the type of experience that you might have enjoyed with, say Active Record, which is kind of like, for me, the gold-standard to which I will compare all RMs.
It definitely has its problems, but I feel like it's a great piece of software. It's probably the closest you're gonna get to that in the Node.js world. That said, this is another situation where if you choose to use Sequelize, the support that you're gonna find out there on the interwebs is not awesome, like there aren't a lot of tutorials. There aren't a lot of resources. There aren't a lot of sample apps that have been built using Sequelize, so you're gonna be a little bit in the wilderness if you use Sequelize.
The documentation is pretty okay, but there's a lot of things that go unsaid that you occasionally have to dive into the source to figure out. But all that said, it definitely is, of all the ORMs out there, on top of a relational database, I think it's definitely the creme de la creme. But yeah, as I mentioned, isn't SQL for old people? Shouldn't we be using NoSQL databases? And there's some reasons why you might want to consider going with a NoSQL database for Node, mostly because the support for NoSQL databases in Node is much better.
There's a lot more folks using those technologies, a lot more resources available, the libraries are a little bit better, for instance, like Mongoose which is the ODM, the Object Document Mapper for MongoDB, I think is particularly good. But the main reason that I've gone to SQL is that Postgres itself is an awesome, feature-rich database and RDS was a good choice within our Amazon-centric ecosystem.
It was gonna be the best data store solution for us, so the opportunity to go with RDS was definitely a driving factor in making that choice.
Note: This course was created by Frontend Masters. It was originally released on 12/28/2016. We're pleased to host this training in our library.
- Serving HTTP requests with Express
- NPM scripts and Grunt
- NPM scripts and Elastic Beanstalk
- The database
- Sequelize and PostgreSQL
- Production environment
- Elastic Beanstalk and RDS
- Provisioning an environment
- Sass and Sass alternatives
- Building with Vue.js
- Real-time user interfaces
- Production monitoring
- Google Universal Analytics