1.10.8 • Published 9 months ago
sito-node-mysql v1.10.8
sito-node-mysql
sito-node-mysql @1.10.1
Create connection
const { connection } = require("sito-node-mysql");
connection.init({host, user, password, database});
// you can initialize your connection in the application
After the creation of the connection you can use the CRUD methods
Functions
Using mysql2
insert (table: string, attributes: string[], values: object)
const { insert } = require("sito-node-mysql");
/* ⚠ If you pass 'id' will override uuid id auto generated ⚠ */
const result = insert("users", ["id", "user", "name"], { user: "sito8943", name: "Sito" })
// sql => INSERT INTO users(id, name) VALUES('<uuid>', 'Sito');
update (table: string, attributes: string[], values: object, where: any)
const { update } = require("sito-node-mysql");
const result = update("users", ["name"], { name: "SitoNumbis" }, { attribute: "user", operator: "=", value: "sito8943" })
// sql => UPDATE users SET name='SitoNumbis' WHERE user='sito8943';
select (table: string || string[], attributes: string[], where: any, start: number, end: number)
const { select } = require("sito-node-mysql");
const result = select("users", ["name"], { attribute: "user", operator: "=", value: "sito8943" })
// sql => SELECT name FROM users WHERE user='sito8943';
deleteDocuments (table: string, where: any)
const { deleteDocuments } = require("sito-node-mysql");
const result = deleteDocuments("users", { attribute: "user", operator: "=", value: "sito8943" })
// sql => DELETE FROM users WHERE user='sito8943';
WHERE syntax !!! IMPORTANT
Where as object (single where)
{
attribute: "string",
operator: "=" // can be =, >, <, >=, <=, <>, BETWEEN, LIKE, IN
value: "string", // or number, NOTE can be and array if you are using IN operator
value1: "string" or number // if you are using BETWEEN operator
parenthesis: string // this will type the 'parenthesis' '(' or ')' exactly in the location
}
Where as array (multi where)
[{
attribute: "string",
operator: "=" // can be =, >, <, >=, <=, <>, BETWEEN, LIKE, IN
value: "string", // or number, NOTE can be and array if you are using IN operator
value1: "string" or number // if you are using BETWEEN operator
logic: "AND", // or "OR" the firs logic will be not taken
}]
1.10.8
9 months ago
1.10.7
9 months ago
1.10.6
9 months ago
1.10.5
9 months ago
1.10.4
9 months ago
1.10.3
9 months ago
1.10.2
9 months ago
1.10.1
10 months ago
1.9.9
11 months ago
1.9.8
11 months ago
1.9.7
11 months ago
1.9.6
11 months ago
1.9.5
11 months ago
1.9.4
11 months ago
1.9.3
11 months ago
1.9.2
11 months ago
1.9.1
11 months ago
1.8.1
11 months ago
1.7.7
11 months ago
1.7.6
11 months ago
1.6.5
11 months ago
1.6.4
11 months ago
1.6.3
11 months ago
1.6.2
11 months ago
1.6.1
11 months ago
1.5.1
11 months ago
1.4.2
11 months ago
1.3.1
11 months ago
1.2.3
11 months ago
1.1.5
11 months ago
1.1.4
11 months ago
1.1.3
11 months ago
1.1.2
11 months ago
1.0.3
11 months ago
1.0.2
11 months ago