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 :: call a function 
Javascript :: uirouter 
Javascript :: google scripts get document 
Javascript :: Query all object in mongo array to satisy condition 
Javascript :: convert a signed 64.64 bit fixed point number online 
Javascript :: sort object with certain value at start of array js 
Javascript :: breakout to external link in react js 
Javascript :: uncaughtException javascript 
Javascript :: apply() js 
Javascript :: react hook usestate 
Javascript :: antd search in select 
Javascript :: key js 
Javascript :: how to assign onEdit to specigfic tab 
Javascript :: how to get form all filed with properties in jquery 
Javascript :: trigger sweet alert through javascript 
Javascript :: while loops js 
Javascript :: react doc viewer 
Javascript :: usememo 
Javascript :: rivets bind 
Javascript :: sending json data uing fetch is empty 
Javascript :: xor operator js 
Javascript :: TypeError: db.collection Name is not a function 
Javascript :: react axios Card List 
Javascript :: calculate age given the birth date in the format yyyymmdd 
Javascript :: if in javascript 
Javascript :: getinitialprops to a hoc in next js 
Javascript :: hide playback speed from videojs 
Javascript :: how to add debounce in react redux js 
Javascript :: hostlistner 
Javascript :: mule 4 json to string json 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =