This application is REST API performing CRUD operations using postgreSQL Database.
The application integrates nodejs and postgresql.
node index.js
You should have nodejs and postgreSQL installed to run this application.
Execute these commands one by one to in psql shell.
-
Make a new User named me. givig him permission to create database.
CREATE ROLE me WITH LOGIN PASSWORD 'password'; ALTER ROLE me CREATEDB;
-
Login with the user me by restarting the shell/session.
-
Create a new Database named API while logged in as user me.
CREATE DATABASE api;
-
Use that database.
\c api
-
Create a new Table
CREATE TABLE users ( ID SERIAL PRIMARY KEY, name VARCHAR(30), email VARCHAR(30) )
-
Add some random values (optional)
INSERT INTO users (name, email) VALUES ('Karan', '[email protected]'), ('Shyam', '[email protected]'), ('Ali', '[email protected]');
pro tip: if you found errors in the code above, check your commas. postgreSQL takes
'
and not"
.
Karan Mittal