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)