Email Login
This commit is contained in:
		@@ -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"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user