
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
gg-mysql-connector
Advanced tools
**`gg-mysql-connector`** is an intuitive MySQL model creator designed to simplify database management and operations by synchronizing TypeScript models with MySQL tables. This package allows you to declare and manage your MySQL database structure programm
gg-mysql-connector
is an intuitive MySQL model creator designed to simplify database management and operations by synchronizing TypeScript models with MySQL tables. This package allows you to declare and manage your MySQL database structure programmatically, with strong type enforcement.
npm install gg-mysql-connector
Start by declaring your database tables and columns as TypeScript variables:
import { MyModel } from "gg-mysql-connector"
const model: MyModel[] = [
{
tableName: "user",
columns: [
{ COLUMN_NAME: "id", DATA_TYPE: "int", AUTO_INCREMENT: true },
{ COLUMN_NAME: "name", DATA_TYPE: "varchar(512)" },
],
},
{
tableName: "item",
columns: [
{ COLUMN_NAME: "id", DATA_TYPE: "int", AUTO_INCREMENT: true },
{ COLUMN_NAME: "name", DATA_TYPE: "varchar(512)" },
{ COLUMN_NAME: "price", DATA_TYPE: "float" },
{
COLUMN_NAME: "status",
DATA_TYPE: "varchar(64)",
POSSIBLE_VALUE: ["ACTIVE", "DISABLE"],
},
{ COLUMN_NAME: "description", DATA_TYPE: "varchar(512)" },
],
},
]
const viewData: MyViewModel[] = [
{
viewName: "item_view",
sqlStatement: SQL`CREATE OR REPLACE VIEW item_view AS SELECT id ,name , amount, price FROM item`,
},
]
Use the provided functions to sync your model with MySQL and generate TypeScript interfaces.
import { ModelGenerator } from "gg-mysql-connector"
const migrator = new ModelGenerator(
{
host: "your-host",
user: "your-user",
password: "your-password",
database: "test_ggdb_connector",
},
model
)
await migrator.init()
await migrator.pushModelToDB()
// from file
await migrator.pushViewToDB("./views")
// from code
await migrator.pushViewToDB_v2(viewData)
await migrator.generateModelInterface({
appName: "app",
model: model,
outputDirectory: ["./"],
})
process.exit()
Once you've generated your interfaces, you can perform type-enforced MySQL operations.
import GGMySQLConnector from "gg-mysql-connector"
import app_INF from "./your-output-directory/app_INF" // Generated in step 2
const db = new GGMySQLConnector<app_INF>({
host: "your-host",
user: "your-user",
password: "your-password",
database: "test_ggdb_connector",
})
await db.init()
// Select operations
const result_1 = await db.select("item")
const result_2 = await db.selectByID("user", 2)
const result_3 = await db.selectByMatchParams("item", { id: 5 })
const result_4 = await db.selectByMatchParams("item", { name: "pen", price: 3 })
// Update operations
const result_5 = await db.update("user", { id: 3, name: "Tony" })
const result_6 = await db.update("item", { id: 3, price: 4, name: "Ruler" })
const result_7 = await db.updateOnlyID("item", { oldID: 7, newID: 4 })
// Delete operations
const result_8 = await db.deleteByID("item", 5)
const result_9 = await db.deleteByMatchParams("item", { name: "pen", price: 5 })
// raw query
const result_10 = await db.query("SELECT * FROM item where id = ?", [5])
MIT License
FAQs
**`gg-mysql-connector`** is an intuitive MySQL model creator designed to simplify database management and operations by synchronizing TypeScript models with MySQL tables. This package allows you to declare and manage your MySQL database structure programm
The npm package gg-mysql-connector receives a total of 15 weekly downloads. As such, gg-mysql-connector popularity was classified as not popular.
We found that gg-mysql-connector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.