1.1.1 • Published 11 months ago

@uwineza/mysql.connect v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

MYSQL DATABASE CONNECTION

Simple Mysql Database Server (MDS) providing comprehensive error message for both development and production as you mention in the .env file

Environment configuration

    IS_PRODUCTION = 1  # 0 - Development server | 1 - Production server
    DB_HOST = localhost
    DB_HOST_USER = root
    DB_HOST_PWD = 
    DB_NAME = test
    DB_POOL_MAX_CONNECTIONS = 10

Usage

@uwineza/mysql.connect is a promise version of connection, therefore to be working with this MySQL connector you should follow the promise rule of javascript. Here is the functional sample code

    const express = require('express');
    const { pool, mysqlMessage } = require('@uwineza/mysql.connect');

    const router = express.Router();

    router.get('/users', async (req, res) => {
        try {
            const [users] = await pool.query("SELECT * FROM users");
            return res.json({ users });
        } catch (err) {
            return mysqlMessage(err, res)
        }
    });
1.1.1

11 months ago

1.1.0

11 months ago

1.0.0

11 months ago