1.0.8 • Published 1 year ago

gupshup-mysql-demodb v1.0.8

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
1 year ago

Run Locally

Set below environment variables for connecting mysql.

GUPSHUP_DB_CONNECTION_URL="00.224.114.86"

GUPSHUP_DB_USERNAME="root"

GUPSHUP_DB_PASSWORD="password"

GUPSHUP_DB_DATABASE="DATABASE_NAME"

For Journey builder, you can setup above mentioned variables as a local/global variable and pass it to initializeMysql method.

Database Connection Code and Query Execution

Sample code for fetching user records

  
//Self executing function for journey codeNode. Which allows user to execute async code.

(async () => {
  try{

    /************************************************************/
    /**********************SET ENV VARIABLES*********************/
    /************************************************************/
    const HOST = process.env.GUPSHUP_DB_CONNECTION_URL;
    const USERNAME = process.env.GUPSHUP_DB_USERNAME; 
    const PASSWORD = process.env.GUPSHUP_DB_PASSWORD;
    const DATABASE = process.env.GUPSHUP_DB_DATABASE; 
    /************************************************************/
    const GupshupDB = require(`gupshup-mysql-demodb`).mysql;

    GupshupDB.initializeMysql( HOST, USERNAME, PASSWORD, DATABASE );
    const userId = 1;
    const name = "John Wick";

    let insert = await GupshupDB.addUser( userId, name ); // Record will get added to table
    let select1 = await GupshupDB.getSingleUser( userId );  // Fetch single record
    let selectAll = await GupshupDB.getAllUsers(); // Fetch all records
    let deleteUser = await GupshupDB.deleteUser( userId ); // Delete specific record


  } catch (e) {
    console.log(e);
  }

})()
1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago