mysql-query-utils
v1.0.0
Published
This module contains helper functions for managing database queries.
Downloads
70
Readme
Database Helper Functions
This module contains helper functions for managing database queries.
Functions
query(db, que, values)
Used for database queries that return a single result.
- Parameters:
db
: Database connection objectque
: SQL queryvalues
: Query parameters
- Returns:
- If result found: First result row
- If no result:
false
queryMulti(db, que, values)
Used for database queries that return multiple results.
- Parameters:
db
: Database connection objectque
: SQL queryvalues
: Query parameters
- Returns:
- If results found: All result rows
- If no results:
false
Usage Example
const qutils = require('mysql-query-utils');
// Single query example
const user = await qutils.query(db, 'SELECT FROM users WHERE id = ?', [userId]);
// Multiple query example
const allUsers = await qutils.queryMulti(db, 'SELECT FROM users', []);
Notes
- Functions are Promise-based
- Errors are thrown
- Returns false when no results are found