0.1.1 • Published 3 years ago

mysql-shortener v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Information

  • Small NPM package that allows you to interact easier with your database.
  • Shortens your database query code up to 10 times!
  • MySQL pool and Promise-Object based, you are able to use .then, .catch etc.
  • Useful for people who keep their code clean and short.

Install

$ npm install mysql-shortener

Basic Usage

const database = require('mysql-shortener');


database.customQuery(`SELECT * FROM customers WHERE customerId = '1234'`).then(function(result) {

//SQL Query will be: `SELECT * FROM customers WHERE customerID = '1234'`

    console.log(result);
    /* Output:

    [
        RowDataPacket {
            customerId: 1234,
            customerName: 'Bob Andrew',
            phone: '123456789'
        }
    ]

    */
})

Functions

.customQuery(query)
// SQL Syntax: `YOUR OWN SYNTAX`

Requirements

You need a .env file with the following information in your project root directory:

SQLS_CONNECTIONLIMIT=connection_limit
SQLS_HOST=host
SQLS_PORT=port
SQLS_USER=user
SQLS_PASSWORD=password
SQLS_DATABASE=database

Automatically create .env file

If you want to have the neccessary .env file created automatically for you instead of making one yourself then simply navigate to the node_modules/mysql-shortener directory (in the console obviously) and enter $ npm run build, a .env file will be automatically created in your project root folder with all the required content. If you already have a .env file in the project root folder and run the command the content will be appended to the file.

Contact

For question, suggestions, ideas etc, feel free to join my Discord server, or create an issue on GitHub.