Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
mysql-database
Advanced tools
Readme
npm i mysql-database
[Note]: Events are only emitted if the action is taken from the library, which means if you manage the database from other connection, events would not work
const MySQL = require('mysql-database');
const database = new MySQL();
// Create Your Own Connection
run();
async function run(){
let db = await database.connect({ // creates a database connection
host: 'localhost',
port: '3306', // the default is 3306
user: 'root',
password: '',
database: 'my_database',
charset: 'utf8mb4'
});
db.on('connected', async connection => { // database connected event
console.log('Database Connected');
});
db.on('dataModification', async event => { // data changes & modifications event
console.log(event);
/*
{
oldData: 'bar',
newData: 'bar2',
type: 'UPDATE',
table: 'test_table',
modifiedAt: 1653815607288
}
*/
});
db.on('tableCreate', async table => {
console.log(`Table ${table} Created`);
});
db.on('tableDelete', async table => {
console.log(`Table ${table} Deleted`);
});
db.on('tableClear', async table => {
console.log(`Table ${table} Data Cleared`);
});
db.on('tableRename', async (oldName, newName) => {
console.log(`Table renamed from ${oldName} to ${newName}`);
});
}
await db.set('my_table', 'foo', 'bar');
// -> Stores 'bar' in 'foo' key name in the table 'my_table'
await db.get('my_table', 'foo');
// -> Gets foo key name value (which is bar) in the table 'my_table'
await db.exists('my_table', 'foo');
// -> Checks if a specific data exists
await db.base_set('my_table', 'foo', 'bar');
// -> Stores 'bar' in 'foo' key name in the table 'my_table' but base encrypted
await db.base_get('my_table', 'foo');
// -> Gets foo key name value (which is bar) in the table 'my_table' for encrypted rows using base_set method
await db.push('my_table', 'fruits', 'banana');
// -> pushs 'banana' to 'fruits' array in 'my_table' table
await db.pull("my_table", "fruits", "banana");
// -> pulls FIRST 'banana' from 'fruits' in 'my_table'
await db.pull("my_table", "fruits", "banana", "all");
// -> pulls ALL 'banana' from 'fruits' in 'my_table'
await db.includes("my_table", "fruits", "banana");
// -> Checks if the array includes provided value
await db.add("my_table", "price", 10);
// -> add 10 to price in 'my_table' table
await db.sub("my_table", "price", 5);
// -> subtracts 5 from price - the remaining is 5 from price in 'my_table' table
await db.all("my_table");
// -> retutn all the data in 'my_table' table
await db.delete("my_table", "foo");
// -> delete foo key in 'my_table' table
await db.tables();
// -> return array of all tables existed in the database
await db.rename("my_table", "new_name");
// -> renames table name
await db.stats("my_table");
// -> return table info
await db.query("DROP TABLE my_table;")
// -> executes a SQL query
await db.auto_increment("my_table", 5);
// -> sets 'my_table' table auto increment to 5
await db.create("table_name");
// -> Create empty table with "table_name" name without inserting any data to it
await db.drop("table_name");
// -> deletes the table 'table_name'
await db.clear("table_name");
// -> clears all 'table_name' table rows & data
await db.variables({
max_connections: 100000,
max_connect_errors: 100000,
wait_timeout: 60
});
// -> modifies any global variable
await db.ping();
// -> gets database ping (in ms)
await db.process();
// -> returns the processes/connections list
await db.end();
// -> closes the connection
© mysql-database, 2021 - 2022 | TARIQ (contact@itariq.dev)
FAQs
Easily modify your MySQL database data with easy functions
The npm package mysql-database receives a total of 4 weekly downloads. As such, mysql-database popularity was classified as not popular.
We found that mysql-database demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.