advanced-mysql
v1.2.0
Published
Advanced Mysql Query Builder
Downloads
42
Maintainers
Readme
advanced-mysql
Advanced Mysql is a Node.js module designed to simplify and streamline interactions with MySQL databases. This package makes it easier to write and manage MySQL queries, allowing you to handle database operations more efficiently and with fewer errors.
Definations
.env
DB_NAME = 'database_name'
FSQL_HOST = 'host'
FSQL_USER = 'user'
FSQL_PASSWORD = 'password'
Usage (module)
.aselect
import ASQL from "advanced-mysql"; //! Or require('advanced-mysql')
(async () => {
const db = new ASQL("host", "user", "passwrod", "database");
await db.createConnection();
const data = await db.aselect({
selects: ["username,profiles.profile_description"],
table: "users",
joins:{
profiles:{
selfKey:'id',
table:'users',
foreignKey:'user_profile' //! Includes profile id
}
}
});
})();
.query (primitive mysql query)
import ASQL from "advanced-mysql"; //! Or require('advanced-mysql')
(async () => {
const db = new ASQL("localhost", "root", "", "yel_emlak");
await db.createConnection();
const data = await db.query('SELECT * FROM users');
})();