DEV Community

Ranak Debnath
Ranak Debnath

Posted on

Tired of writing repetitive MySQL code in Node.js? Hereโ€™s a simple helper I built! - mysql2-helper-lite

๐Ÿš€ Introducing mysql2-helper-lite โ€“ A Lightweight MySQL Helper for Node.js Developers!

Iโ€™m excited to launch mysql2-helper-lite, a powerful yet lightweight helper library designed to simplify database operations with mysql2/promise. If youโ€™re tired of writing repetitive SQL queries and managing complex transactions manually, this package is for you!

๐Ÿ”ฅ Why Use mysql2-helper-lite?

โœ… Less Boilerplate Code โ€“ Perform database operations with simple function calls instead of writing raw SQL.
โœ… Easy Insert & Update โ€“ Pass objects directly to insert or update queries, no need to manually write field names.
โœ… Automatic Joins โ€“ Easily join related tables without writing complex SQL joins.
โœ… Transaction Handling โ€“ Execute multiple queries in a single transaction with built-in rollback support.
โœ… Audit Logging โ€“ Keep track of changes with automatic audit logs.
โœ… Auto-generate REST APIs โ€“ Create APIs in seconds with Express integration.

๐Ÿ› ๏ธ Installation & Usage

Install via NPM:

npm install mysql2-helper-lite

Example Usage:

const db = require('mysql2-helper-lite');

// Insert a record
await db.insert('users', { name: 'John Doe', email: 'john@example.com' });

// Fetch data with conditions
const users = await db.select('users', { where: { email: 'john@example.com' } });

console.log(users);

This package is designed for developers who value efficiency and want to focus on building features rather than handling repetitive database queries.

Check it out & let me know your thoughts!
๐Ÿ”— Git-https://github.com/piyaldeb/mysql2-helper-lite
Npm - https://www.npmjs.com/package/mysql2-helper-lite
๐Ÿ“ฆ npm install mysql2-helper-lite

NodeJS #MySQL #NPM #WebDevelopment #OpenSource #DatabaseOptimization

Top comments (0)