Postingan

Menampilkan postingan dengan label NodeJS

PostgreSQL UPSERT

Example SQL Syntax: INSERT INTO student (id, name)     VALUES (5, 'Nasohi Ciptandani')     ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name; Example Node.js code queries.js file:    const Pool = require('pg').Pool    const pool = new Pool({     user: 'monitoring',     host: 'localhost',     database: 'monitoring',     password: 'p4ssw0rd',     port: 5432,    })      pool.query("DELETE FROM linux_server_status", (error, results) => {      console.log(error, results);   });   const createLinux = (request, response) => {    const {hostname, ip, os, hdd_total, hdd_used, hdd_free, mem_total, mem_free, mem_used, core } = request.body    const now = new Date();    pool.query('INSERT INTO linux_server_status (hostname, ip, os, hdd_total, hdd_used, hdd_free, mem_total, mem_free, mem_used, co...