1.0.9 • Published 1 year ago

node-mysql-queries v1.0.9

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

MySQL Queries For Node.js

Functions to help SQL queries from Node.js to MySQL.

Pre-Requirements

MySQL js (https://github.com/mysqljs/mysql)

$ npm install mysql

or

$ npm install mysqljs/mysql

Dotenv (https://github.com/motdotla/dotenv)

$ npm install dotenv --save

Create .env file like or add lines to your .env file;

DB_HOST=your_db_host
DB_USER=your_db_username
DB_PASSWORD=your_db_password
DB_DATABASE=your_db_database_name

Installation

npm i node-mysql-queries

Usage

SELECT * FROM table_name

res = controller response table_name = string (table name)

selectAllSQL(res, 'table_name')

SELECT * FROM table_name WHERE column_name = value

res = controller response table_name = string (table name) columns = string array (columns name) You can use multiple column like 'col1', 'col2' values = array (values) You can use multiple value like 1, 'val2'

selectWhereSQL(res, 'table_name', ['column_name'], [values])

INSERT INTO posts SET id = 1, title = 'Hello World'

res = controller response table_name = string (table name) value = object for example: {id: 1, title: 'Hello World'}

insertSQL(res, 'table_name', {value})

UPDATE teble_name SET col1 = val1, col2 = val2 WHERE id = 1

res = controller response table = string (table name) columns = string array (columns name) You can use multiple column like 'col1', 'col2' values = array (values) You can use multiple value like 1, 'val2' where = string like (id = 1)

updateSQL(res, 'table', ['columns'], [values], 'where')

DELETE FROM table_name WHERE column = value

res = controller response table_name = string (table name) column = string (column name) value = string (value)

deleteSQL(res, 'table_name', 'column', 'value')

Results

Want to contribute?

You can read and follow our CONTRIBUTING.md and report it using GitHub Issues! for reporting bugs, suggesting enhancements, bugfixes, new features and extras are welcome.

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

1.0.9

1 year ago

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