← Node.js & Express learning pathNode.js & Express · Module 8 of 10
Databases with Node
Store data in MongoDB or SQL databases from Express.
📖 Key ideas
- MongoDB with Mongoose: schemas and models.
- SQL (PostgreSQL/MySQL) with pg, mysql2 or an ORM like Prisma.
- Keep connection strings in environment variables.
- Use parameterised queries to avoid SQL injection.
- Handle database errors and return clean messages.
💡 Real-life example: An ORM is a translator: you speak JavaScript, it speaks SQL to the database.
MongooseMongoDB modelling library
PrismaType-safe ORM
Parameterised queryQuery with placeholders for values
Connection stringURL with database credentials