Skip to main content

Data for Expresss

Database integration in Express connects route handlers to persistent storage, using a driver such as pg or mongodb, a query builder, or an ORM such as Prisma or Sequelize. Good practice is a connection pool created once at start-up and a separate data-access layer so handlers stay thin.

Stage: Building APIs · Part of the Express roadmap · Last reviewed 19 November 2026

What to learn in Data

Data interview questions

Why use a connection pool instead of opening a connection per request?

Opening a database connection is slow and databases limit how many can be open. A pool keeps a set of connections ready and shares them across requests, which lowers latency and prevents overloading the database.

How do you stop SQL injection in an Express app?

Never build SQL by concatenating request values. Use parameterised queries or an ORM that binds parameters, so the database treats input purely as data. Validating input and using a least-privilege database account add further protection.

Where Data fits in the Express roadmap

Data belongs to the Building APIs stage (beginner level). Real endpoints.

Back to the full Express roadmap