Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node js postgresql query

// callback
client.query('SELECT NOW() as now', (err, res) => {
  if (err) {
    console.log(err.stack)
  } else {
    console.log(res.rows[0])
  }
})
// promise
client
  .query('SELECT NOW() as now')
  .then(res => console.log(res.rows[0]))
  .catch(e => console.error(e.stack))
Comment

postgresql nodejs

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()})()
Comment

PREVIOUS NEXT
Code Example
Javascript :: split array by character javascript 
Javascript :: learn javascript 
Javascript :: format numbers js 
Javascript :: what are array methods in javascript 
Javascript :: spread 
Javascript :: js promise example 
Javascript :: js index of 
Javascript :: brightness javascript 
Javascript :: javascript basic programs 
Javascript :: localstorage in next js 
Javascript :: string get a letter by index 
Javascript :: javascript extract array from object 
Javascript :: angular number validation 
Javascript :: event.target 
Javascript :: click function in js 
Javascript :: getDownload url in firebase 
Javascript :: how to remove an item from an object in javascript 
Javascript :: type conversion in javascript 
Javascript :: sub function javascript 
Javascript :: react spring transition animations 
Javascript :: create responsive navbar without javascript 
Javascript :: mongoose find by nested property 
Javascript :: use state in className 
Javascript :: javaScript Math.log() Method 
Javascript :: arrow function syntax vs function expression syntax 
Javascript :: update TextInput value react-hook-form react-admin 
Javascript :: how to wait for the subscribe to finish before going back to caller method in angular 
Javascript :: types of method in js 
Javascript :: function syntax js 
Javascript :: define conastant js 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =