📚 Tutorial💻 Random JS LibPostgresSQL

PostgresSQL (pg)

Basic start up

https://www.npmjs.com/package/pg

Terminal
npm install pg

Connect and run query

server.ts
import { Client } from 'pg';
 
export const client = new Client({
    database: "test_db",
    user: "postgres",
    password: "my_passowrd_123"
});
 
( async () => {
    const result = await client.query('SELECT * from users where username = $1', ["tom"]);
    const dataArr = result.rows
})()