nodedb-helper

1.4.1 • Public • Published

nodedb-helper

mysql helper

This package helps optimize mysql connection for re-use. You can manage multiple databases using this package easily.

setup

set .env variables for production and development

NODE_ENV=development

PROD_DB_URL=mysql_url
PROD_DB_USERNAME=mysql_admin
PROD_DB_PASSWORD=abcdefgh

DEV_DB_URL=localhost
DEV_DB_USERNAME=root
DEV_DB_PASSWORD=

setup database.js for re-use

const db = require('nodedb-helper')({
	user: 'my_user_db',
	product: 'my_product_db'
})

module.exports = db;

use in product.js

const db = require('./database.js');

let result = await db.product().select({
	table: 'product_details',
	where: 'product_id=?',
	params: [123]
});

Package Sidebar

Install

npm i nodedb-helper

Weekly Downloads

6

Version

1.4.1

License

ISC

Unpacked Size

19.5 kB

Total Files

10

Last publish

Collaborators

  • harshkanjariya