Menu

How the PERN stack talks to its database, tried in 30 minutes
📰

How the PERN stack talks to its database, tried in 30 minutes

DEV Community: node·Saarathi Academy·about 13 hours ago
#KWsA6XAK
#devtonodejs#devto#dev#postgresql#query
Reading 0:00
15s threshold

In the PERN stack, Express never talks to PostgreSQL by itself. A small library called node-postgres, installed as pg , carries every query from your Node.js code to the database and brings the rows back.

Most beginner tutorials hurry past this piece to get to React. We think it is the part to slow down on. The way you pass data into a query decides whether your first app can be broken with one line typed into a URL. This article explains what pg does and walks you through one working route in about 30 minutes, with free tools.

What does pg do in the PERN stack?

PERN stands for PostgreSQL, Express, React and Node.js. We explain the four letters, and how they compare with MERN, in our guide to MERN vs PERN for web development training in Nepal . Here we look only at the line between the E and the P.

React sends a request. An Express route on Node.js receives it. That route needs data, so it hands a SQL query to pg .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.