Data for Node.jss
Data in a Node.js backend means persistent storage. Relational work uses a driver or ORM such as Prisma, Sequelize or Knex against PostgreSQL or MySQL, while MongoDB suits document data. Redis is often added as a cache or session store to cut repeated database reads.
Stage: Web APIs · Part of the Node.js roadmap · Last reviewed 19 November 2026
What to learn in Data
- Connect to a SQL database using a connection pool
- Write parameterised queries to avoid SQL injection
- Model tables and relations with an ORM and run migrations
- Store and query documents in MongoDB with Mongoose
- Cache a slow query result in Redis with an expiry time
Data interview questions
Why use a connection pool in a Node.js app?
Opening a database connection per request is slow and can exceed the server limit. A pool keeps a fixed set of open connections and lends them out, which lowers latency and caps load on the database during traffic spikes.
When would you choose MongoDB over PostgreSQL in Node.js?
Choose MongoDB when data is document-shaped, varies in structure and is mostly read as a whole. Choose PostgreSQL when you need joins, strict schemas and transactions across tables. Many apps do well with PostgreSQL because it also stores JSON.
Where Data fits in the Node.js roadmap
Data belongs to the Web APIs stage (intermediate level), which takes about 22 hours. Serve requests.
Other units in this stage
Back to the full Node.js roadmap