Skip to content

pardeepsingh1999/node-postgreSql

Repository files navigation

const text = 'INSERT INTO users(name, email, password, age) VALUES($1, $2, $3, $4) RETURNING *'
const values = ['pardeep', '[email protected]', 'pp', 21]

const query = `
    CREATE TABLE users (
        email varchar PRIMARY KEY NOT NULL,
        name varchar NOT NULL,
        password varchar NOT NULL,
        age int NOT NULL
    );
`;


promise
client
  .query('SELECT NOW() as now')
  .then(res => console.log(res.rows[0]))
  .catch(e => console.error(e.stack))

client
.query("SELECT * FROM users WHERE email='[email protected]'")
.then(res => console.log(res.rows.length))
.catch(err => console.log(err))

client
  .query(query)
  .then(res => {
      console.log('Table is successfully created');
  })
  .catch(err => {
      console.error(err);
  })
  .finally(() => {
      client.end();
  });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published