npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

algaeh-mysql

v1.5.2

Published

algaeh mysql connection handling and processing request

Readme

algaeh-mysql

This package is developed as per our company need. it may help others. algaeh-mysql is completely promise base api and developer has the facility to release connection where ever it required.

Importing

import algaehMysql from "algaeh-mysql";
Creating instance

const _mysql = new algaehMysql();
Configure MYSQL Connection

By default configuration took from the path root of current working directory. path.join(process.cwd(), "../keys/keys.js") even you can pass the connection configuration to the 'algaehMysql' instance

const _mysql = new algaehMysql({
  path: {
    mysqlDb: {
      host: "localhost",
      port: 3306,
      user: "root",
      password: "****",
      database: "Optional",
      multipleStatements: true
    }
  }
});

Or by passing configuration file path

const _mysql = new algaehMysql({
  path: "file path"
});
Code Syntax

Simple select

_mysql
  .executeQuery({
    query: "select * from table_name where table_id=?",
    values: [10],
    printQuery: true
  })
  .then(result => {
    _mysql.releaseConnection();
    //result ...........
  })
  .catch(error => {
    _mysql.releaseConnection();
    //error .........
  });

the above basic example execute a simple query.

| Field | Description | | ----------------- | ------------------------------------------------- | | executeQuery | method execute without transaction | | query | query string | | values | array of values | | printQuery | it print the query on console in development mode | | releaseConnection | method to release the perticular connection |

[========]

** Bulk insert ,replace keys and exclude values and extravalues**

_mysql
  .executeQuery({
    values: [
      { algaeh_d_formulas_id: 3, formula_for: "Testing", status: "A" },
      { algaeh_d_formulas_id: 4, formula_for: "Testing1", status: "I" }
    ],
    extraValues: {
      formula: "A+B"
    },
    excludeValues: ["formula_for"],
    replcaeKeys: { status: "record_status" },
    query: "insert into  algaeh_d_formulas (??) values ?",
    printQuery: true,
    bulkInsertOrUpdate: true
  })
  .then(result => {
    _mysql.releaseConnection();
    //result -----------
  })
  .catch(error => {
    _mysql.releaseConnection();
    //error -----------
  });

| Field | Description | | ------------------ | ------------------------------------ | | extraValues | insert extra values | | replcaeKeys | replace key name with other key name | | bulkInsertOrUpdate | is true for array of objects |

[========]

**Bulk update ,replace keys and exclude values and extravalues **

_mysql
  .executeQuery({
    values: [
      {
        algaeh_d_formulas_id: 4,
        formula_for: "Testing1",
        status: "I"
      }
    ],
    extraValues: {
      formula: "A+B"
    },
    excludeValues: ["formula_for"],
    replcaeKeys: { status: "record_status" },
    where: ["algaeh_d_formulas_id"],
    query: "update  algaeh_d_formulas set ? where algaeh_d_formulas_id=?",
    printQuery: true,
    bulkInsertOrUpdate: true
  })
  .then(result => {
    _mysql.releaseConnection();
    // result ---------
  })
  .catch(error => {
    _mysql.releaseConnection();
    //error
  });

[========]

** Execute with transaction **

_mysql
  .executeQueryWithTransaction({
    query: "insert into tableName(`a`,`b`) values(?,?)",
    values: ["aaa", "bbb"],
    printQuery: true
  })
  .then(result => {
    const id = result.insertId;
    _mysql
      .executeQuery({
        query: "insert into tableNameX(`id`,'x') values(?,?)",
        values: [id, "xyz"],
        printQuery: true
      })
      .then(finalresult => {
        _mysql.commitTransaction((error, resu) => {
          if (error) {
            _mysql.rollBackTransaction();
            //error-------
          } else {
            //resu =Success;
            _mysql.releaseConnection();
            //finalresult --------------
          }
        });
      })
      .catch(error => {
        _mysql.rollBackTransaction(() => {
          //error --------
        });
        //or _mysql.rollBackTransaction();
      });
  })
  .catch(error => {
    _mysql.rollBackTransaction(() => {
      //error --------
    });
    //or _mysql.rollBackTransaction();
  });

[========]

to get connection at anypoint of time by calling the funtion

_mysql.getMysqlConnection((error, connection) => {
  if (error) {
    //error---------
  } else {
    //connection
  }
});

to format our as sql string

let query = "";
for (let i = 0; i < 10; i++) {
  query = _mysql.mysqlQueryFormat(
    "insert into tableName(`a`,`i`) values(?,?)",
    ["a" + i, i]
  );
}