
Lesson Description
The "PostgreSQL & ORMs" Lesson is part of the full, API Design in Node.js, v5 course featured in this preview video. Here's what you'd learn in this lesson:
Scott discusses Postgres as a versatile open-source database with features like JSON and geospatial search. He emphasizes using Node.js with Postgres for its ecosystem and ORM support, explaining ORMs provide type safety and help prevent SQL injection.
Transcript from the "PostgreSQL & ORMs" Lesson
[00:00:00]
>> Scott Moss: Postgres or PSQL or PostgreSQL, no, plus Node JS, yeah, I think it's, I mean, Postgres is probably the most popular database in the world depending on who you ask, it's definitely the most sought after, I guess technically SQLite would be the most used database in the world, but. People are doing different things with that than they are with Postgres. It, has tons of different data types. It has JSON arrays, custom types.
[00:00:16]
It has JSON arrays, custom types. You got like full text search GIS that's like Geospatial search, so like you can put in like a longitude and a latitude and it'll triangulate. It'll do math. It'll do Geospatial math on where those things are to be fair, a lot of databases do that too.
[00:00:30]
It'll do Geospatial math on where those things are to be fair, a lot of databases do that too. It's pretty good for complex queries if you, if you're into that stuff. And it's Open Source, that's the, that's the, that's the great thing, and, you know, no one really owns it, And then, yeah, with no, there's just so many integrations to integrate with Postgres, it's insane. Async/Await makes it really good and the reason I'm putting that here is because Using a database with a not Node, like using a Python without something like async/await.
[00:00:47]
Async/Await makes it really good and the reason I'm putting that here is because Using a database with a not Node, like using a Python without something like async/await. Just feels bad. Very strong ecosystem, like I said, tons of options for ORMs. And TypeScript support in my opinion.
[00:00:59]
And TypeScript support in my opinion. It's really good like just be able to have typed support for your database is just, it's just so good like I just, I would never trade that up so really love that. What is an ORM? ORM I guess technically stands for object relational mapping.
[00:01:18]
ORM I guess technically stands for object relational mapping. It's just some old term. It's the SDK for your database, OK? That's what the ORM is.
[00:01:35]
That's what the ORM is. It's the SDK for your database. This is how you talk to your database in your code, is by using your ORM. OK, there are tons of them.
[00:01:54]
OK, there are tons of them. There are tons of ORMs that support tons of different databases, they all had to do it very differently. And there's always gonna be more of them. But that's all an ORM is.
[00:02:07]
But that's all an ORM is. In fact, I almost never wanna call it an ORM again cause I don't actually understand object relational map. I mean, I get it, but why? It's an SDK for your database, OK?
[00:02:25]
It's an SDK for your database, OK? Without that, this is what it will look like on the left to interact with your database. You would get like some super low level Client and you would just pass in your vanilla SQL. Yeah, I'm never doing that.
[00:02:39]
Yeah, I'm never doing that. That's never gonna be me. I'm not gonna be that person. If I had to, I would, but then I'll complain about it, OK?
[00:02:58]
If I had to, I would, but then I'll complain about it, OK? And I don't wanna do it again. I don't want to do this either. This is not something I ever wanna do.
[00:03:16]
This is not something I ever wanna do. I'd rather do something like this. This feels good, OK? This is what an ORM will give you.
[00:03:33]
This is what an ORM will give you. Type Safe, super easy functions to use. Everything's good to go. You don't need to know this stuff.
[00:03:47]
You don't need to know this stuff. Which is pure sequel, by the way. You know, and then It does help with things like potential SQL injection and stuff like that, but honestly, why would you stick. You know, raw.
[00:03:54]
You know, raw. SQL queries from users into your database without sanitizing it's like I don't know why would you do that anyway? I mean you could technically could do that on the ORM too you could put raw SQL here too and solve the same problems you're not actually safe, but I think for me it's mostly just the fact that I don't need to know this because I really think that if you wanted to. You could go really deep on SQL and become a sequel god and like go charge millions of dollars to just do SQL queries for a living cause that's how deep this goes and I know enough SQL to get the job done, but I don't wanna know more than that and I refuse to learn more.
[00:03:54]
You could go really deep on SQL and become a sequel god and like go charge millions of dollars to just do SQL queries for a living cause that's how deep this goes and I know enough SQL to get the job done, but I don't wanna know more than that and I refuse to learn more. So I think it just saves you from that and obviously the Type Safety, the Type Safety is just OD like it's just, it's too good, so we'll be using that, Super easy and it also helps us with our schema. We'll talk about that a little bit.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops