Gathering detailed insights and metrics for mysql-await
Gathering detailed insights and metrics for mysql-await
Gathering detailed insights and metrics for mysql-await
Gathering detailed insights and metrics for mysql-await
npm install mysql-await
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
40 Commits
2 Forks
1 Watchers
1 Branches
2 Contributors
Updated on Apr 07, 2023
Latest Version
2.2.3
Package Id
mysql-await@2.2.3
Unpacked Size
29.39 kB
Size
5.27 kB
File Count
7
NPM Version
8.9.0
Node Version
12.14.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Simple wrapper for MySQL async/await functionality. Intended for functionality to mimic the popular mysql Node.js callback-based package, but with additional methods for awaiting execution. Goal is for normal methods to be unaffected and only additional await methods added, though accomplished through intermediary class objects.
1npm i mysql-await
The methods below have been added as async/await wrappers to existing MySQL methods of similar name. In order to use them, simply "await" their execution rather than passing a callback for the last argument of the function call. For original methods for which "await" methods may have been added, as needed, see the mysql library.
1{ 2 "connectionLimit" : 10, 3 "host" : "example.org", 4 "user" : "bob", 5 "password" : "secret", 6 "database" : "my_db", 7 "throwErrors" : false 8}
Note: throwErrors
is used to determine whether MySQL errors should be thrown AND emitted, or only emitted
1const fs = require(`fs`); 2const mysql = require(`mysql-await`); 3 4/** Self-executing asynchronous function so we can await results in this example */ 5(async () => { 6 /** Create connection pool using loaded config */ 7 const connection = mysql.createConnection(JSON.parse(fs.readFileSync(`mysql-config.json`))); 8 9 connection.on(`error`, (err) => { 10 console.error(`Connection error ${err.code}`); 11 }); 12 13 /** Perform query on connection */ 14 let result = await connection.awaitQuery(`SELECT * FROM people WHERE lastName = ?`, [`Doe`]); 15 16 /** Log output */ 17 console.log(result); 18 19 /** Begin a new transaction */ 20 await connection.awaitBeginTransaction(); 21 22 /** Perform query for max id number in users table */ 23 result = await connection.awaitQuery(`SELECT MAX(id) maxId FROM people`); 24 25 /** Add one to max id to get new id number */ 26 const newId = result[0].maxId + 1; 27 28 /** Insert new test user with new id number */ 29 await connection.awaitQuery(`INSERT INTO people (id, firstName, lastName, age) VALUES (?, ?, ?, ?)`, [newId, `Ebenezer`, `Scrooge`, 142]); 30 31 /** Commit transaction */ 32 await connection.awaitCommit(); 33 34 /** End the connection */ 35 connection.awaitEnd(); 36})(); 37
1[ 2 RowDataPacket { id: 3, firstName: 'Jane', lastName: 'Doe', age: 45 } 3]
1const fs = require(`fs`); 2const mysql = require(`mysql-await`); 3 4/** Self-executing asynchronous function so we can await results in this example */ 5(async () => { 6 /** Create connection pool using loaded config */ 7 const pool = mysql.createPool(JSON.parse(fs.readFileSync(`mysql-config.json`))); 8 9 pool.on(`acquire`, (connection) => { 10 console.log(`Connection %d acquired`, connection.threadId); 11 }); 12 13 pool.on(`connection`, (connection) => { 14 console.log(`Connection %d connected`, connection.threadId); 15 }); 16 17 pool.on(`enqueue`, () => { 18 console.log(`Waiting for available connection slot`); 19 }); 20 21 pool.on(`release`, function (connection) { 22 console.log(`Connection %d released`, connection.threadId); 23 }); 24 25 const connection = await pool.awaitGetConnection(); 26 27 connection.on(`error`, (err) => { 28 console.error(`Connection error ${err.code}`); 29 }); 30 31 /** Perform query on connection */ 32 let result = await connection.awaitQuery(`SELECT * FROM people WHERE lastName = ?`, [`Smith`]); 33 34 /** Log output */ 35 console.log(result); 36 37 /** Release connection */ 38 connection.release(); 39 40 /** Perform query on pool (opens a connection, runs query, releases connection) */ 41 result = await pool.awaitQuery(`SELECT * FROM people WHERE age = ?`, [45]); 42 43 /** Log output */ 44 console.log(result); 45 46 /** Get a new connection from the pool */ 47 const connection2 = await pool.awaitGetConnection(); 48 49 /** Begin a new transaction */ 50 await connection2.awaitBeginTransaction(); 51 52 /** Perform query for max id number in users table */ 53 result = await connection2.awaitQuery(`SELECT MAX(id) maxId FROM people`); 54 55 /** Add one to max id to get new id number */ 56 const newId = result[0].maxId + 1; 57 58 /** Insert new test user with new id number */ 59 await connection2.awaitQuery(`INSERT INTO people (id, firstName, lastName, age) VALUES (?, ?, ?, ?)`, [newId, `Jacob`, `Marley`, 147]); 60 61 /** Commit transaction */ 62 await connection2.awaitCommit(); 63 64 /** Release connection */ 65 connection2.release(); 66 67 /** Close connection pool */ 68 await pool.awaitEnd(); 69})();
1Connection 16 connected 2Connection 16 acquired 3[ 4 RowDataPacket { 5 id: 2, 6 firstName: 'John', 7 lastName: 'Smith', 8 age: 37 9 } 10] 11Connection 16 released 12Connection 16 acquired 13Connection 16 released 14[ 15 RowDataPacket { id: 3, firstName: 'Jane', lastName: 'Doe', age: 45 } 16] 17Connection 16 acquired 18Connection 16 released
Please open an issue for any bugs found or feature requests
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More