postgresql nodejs
//connect to postgres database in node
const Pool = require('pg').Pool;
const pool = new Pool({
user: '',
host: 'localhost',
database: '',
password: '',
port:5432,
})
//query example
app.get('/users',async(req,res)=>{
try{
let resp=await pool.query('SELECT * FROM users');
}catch(err){
res.status(200).send(resp.rows);
}
})
//connect to postgres database in node
const Pool = require('pg').Pool;
const pool = new Pool({
user: '',
host: 'localhost',
database: '',
password: '',
port:5432,
})
//query example
app.get('/users',async(req,res)=>{
try{
let resp=await pool.query('SELECT * FROM users');
}catch(err){
res.status(200).send(resp.rows);
}
})
const { Client } = require('pg')const client = new Client();(async () => { await client.connect() const res = await client.query('SELECT $1::text as message', ['Hello world!']) console.log(res.rows[0].message) // Hello world! await client.end()})()
Also in JavaScript:
- js pixelated
- jspdf cdn
- javascript check if string is number
- mongodb unwind
- lodash remove element from list
- get json data when we get error code in axios
- javascript detect textarea change
- electron send message from renderer to main
- react router dom
- express octet stream
- convert datetime to timestamp javascript
- how to change color of font in js
- add slashes to string
- Module Error (from ./node_modules/eslint-loader/dist/cjs.js):
- install gatsbyjs using npx
- react start new app
- best way to detect mobile device jquery
- escaped json to json javascript
- javascript loop through object properties
- how to see my timezone using js
- jquery add remove class clicked element
- clone an object in javascript
- how to select a class and then change the children of that class with javascript
- javascript array.find