PostgreSQL
Implementation:
Step 1: Setup a server site application
Prerequisites
npm install express pg cors body-parser const express = require('express');
const { Client } = require('pg');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
app.use(cors());
app.use(bodyParser.json());
const port = 5000;
const client = new Client({
user: 'postgres', // username of postgreSQL database
host: 'localhost', // host of postgreSQL database
database: '', // name of the database
password: '', // password of your postgreSQL application
port: 5432, // default port 5432
});
client.connect();
//method to interact with the database
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});Run the express server
Step 2: Setup a client site application
Prerequisites
Example: Retrieve data and display on screen
Last updated