Email Login

This commit is contained in:
Georg Reisinger
2019-02-24 19:27:42 +01:00
parent f853a2bf0f
commit 3baf79e8f6
39 changed files with 3246 additions and 2982 deletions

View File

@ -1,9 +1,9 @@
module.exports ={
postgresSQL:{
user:"smartshopper-user",
host:"188.166.124.80",
database:"smartshopperdb",
password:"jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
port:"5432"
module.exports = {
postgresSQL: {
user: "smartshopper-user",
host: "188.166.124.80",
database: "smartshopperdb",
password: "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
port: "5432"
}
}
}

View File

@ -1,45 +1,44 @@
const { Client } = require ("pg");
const {postgresSQL} = require("./keys")
const {
Client
} = require("pg");
const {
postgresSQL
} = require("./keys")
const client = new Client(postgresSQL);
async function connect() {
try{
await client.connect();
console.log("Database connected!");
}
catch(error)
{
try {
await client.connect();
console.log("Database connected!");
} catch (error) {
console.error(error)
}
}
connect();
async function query(queryString,param)
{
async function query(queryString, param) {
try {
let result = await client.query(queryString,param);
let resultarray = [];
for(let row of result.rows)
{
resultarray.push(row.obj);
}
return resultarray;
}
catch(error)
{
let result = await client.query(queryString, param);
let resultarray = [];
for (let row of result.rows) {
resultarray.push(row.obj);
}
return resultarray;
} catch (error) {
console.log(error)
}
}
async function nonQuery(queryString,param) {
async function nonQuery(queryString, param) {
try {
await client.query(queryString,param);
await client.query(queryString, param);
} catch (error) {
console.error(error)
}
}
module.exports = {
query, nonQuery
query,
nonQuery
}