Where should I look for database integration in the official Node.js documentation?
Asked by
MellowCedar42
I'm having trouble finding a section in the official Node.js documentation that explains how to connect to and work with databases. Is database integration covered in the Node.js API docs, or should I be looking somewhere else for guidance?
Answers
The usual options are a low-level driver such as pg or mysql2, a query builder such as Knex or Kysely, or an ORM like Prisma, Drizzle, or Sequelize. Drivers give you the most control and expose the SQL directly, while query builders and ORMs provide more abstraction and may include migrations or typed models.
Reply to this answer
Node.js itself doesnโt provide a universal database API, so the core documentation doesnโt have a general database-integration section. You normally install a client library for the database you use and follow its documentationโfor example, pg for PostgreSQL, mysql2 for MySQL, or a SQLite library for local databases.
Reply to this answer
For learning the basics, use the documentation for the specific database package rather than searching the Node.js API docs. For a new MySQL project, mysql2 is generally a better choice than the older mysql package because it has stronger promise support and is more actively used.
Reply to this answer
Think of Node.js as the runtime that provides things like networking, streams, and the event loop. The database driver is the part that actually speaks the database protocol. Start with the driverโs README and try a simple parameterized query; thatโs also important for avoiding SQL injection. Add an ORM later if your project needs models, migrations, or a larger data-access layer.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions