zormz 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs +591 -0
- package/dist/index.d.cts +266 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +538 -0
- package/package.json +50 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
|
|
9
|
+
// conection/db.ts
|
|
10
|
+
var conexion1;
|
|
11
|
+
var BDconnection = class {
|
|
12
|
+
constructor(bd, datos) {
|
|
13
|
+
this.tipo = "pg";
|
|
14
|
+
this.tipo = bd;
|
|
15
|
+
this.connection = datos;
|
|
16
|
+
}
|
|
17
|
+
async connecionMyql() {
|
|
18
|
+
try {
|
|
19
|
+
const mysql = await import("mysql2/promise");
|
|
20
|
+
if ("connectionString" in this.connection)
|
|
21
|
+
throw new Error("La conexion mysql no tiene una conexion de red");
|
|
22
|
+
const pool = mysql.createPool({
|
|
23
|
+
host: this.connection.host,
|
|
24
|
+
port: this.connection.port,
|
|
25
|
+
database: this.connection.database,
|
|
26
|
+
user: this.connection.user,
|
|
27
|
+
password: this.connection.password
|
|
28
|
+
});
|
|
29
|
+
return pool;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error("Mysql no esta instalado . para instalarlo corre : npm install mysql2 ");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async connectionPG() {
|
|
35
|
+
try {
|
|
36
|
+
const { Pool } = await import("pg");
|
|
37
|
+
if ("connectionString" in this.connection) {
|
|
38
|
+
console.log("conexion en linea");
|
|
39
|
+
return new Pool({
|
|
40
|
+
connectionString: this.connection.connectionString,
|
|
41
|
+
ssl: {
|
|
42
|
+
rejectUnauthorized: false
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return new Pool({
|
|
47
|
+
host: this.connection.host,
|
|
48
|
+
port: this.connection.port,
|
|
49
|
+
database: this.connection.database,
|
|
50
|
+
user: this.connection.user,
|
|
51
|
+
password: this.connection.password
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(
|
|
55
|
+
"PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async executeConsulta({
|
|
60
|
+
query,
|
|
61
|
+
valores = void 0,
|
|
62
|
+
mensaje
|
|
63
|
+
}) {
|
|
64
|
+
try {
|
|
65
|
+
if (this.tipo === "mysql") {
|
|
66
|
+
const pool = await this.connecionMyql();
|
|
67
|
+
const [rows] = await pool.query(query, [valores]);
|
|
68
|
+
return rows;
|
|
69
|
+
} else if (this.tipo === "pg") {
|
|
70
|
+
let query2 = query;
|
|
71
|
+
if (valores) {
|
|
72
|
+
let iterador = 1;
|
|
73
|
+
query2 = "";
|
|
74
|
+
for (let i = 0; i < query.length; i++) {
|
|
75
|
+
if (query[i] == "?") {
|
|
76
|
+
query2 += `$${iterador}`;
|
|
77
|
+
iterador++;
|
|
78
|
+
} else {
|
|
79
|
+
query2 += query[i];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const pool2 = await this.connectionPG();
|
|
84
|
+
const respuesta = await pool2.query(query2, valores);
|
|
85
|
+
if (!respuesta) {
|
|
86
|
+
throw new Error(` Este usuario no esta registrado `);
|
|
87
|
+
}
|
|
88
|
+
if ("rows" in respuesta) {
|
|
89
|
+
if (respuesta.rows[0].id) {
|
|
90
|
+
return { insertId: respuesta.rows[0].id };
|
|
91
|
+
}
|
|
92
|
+
return respuesta.rows;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.log(error);
|
|
97
|
+
if (typeof error === "object" && error !== null && "code" in error) {
|
|
98
|
+
if (error.code === "ETIMEDOUT") {
|
|
99
|
+
throw new Error(`Su red esta limitando el acceso`);
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`${mensaje} : ${error} query ${query}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function getConexion(bd, datos) {
|
|
107
|
+
conexion1 = new BDconnection(bd, datos);
|
|
108
|
+
}
|
|
109
|
+
function getRed() {
|
|
110
|
+
return conexion1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// conection/middleware/delete.ts
|
|
114
|
+
var _condicion, _tabla;
|
|
115
|
+
var DeleteR = class {
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param {string} tabla -- tabla a eliminar
|
|
119
|
+
* @example
|
|
120
|
+
* delete from tabla
|
|
121
|
+
*/
|
|
122
|
+
constructor(conexion, tabla) {
|
|
123
|
+
__privateAdd(this, _condicion);
|
|
124
|
+
__privateAdd(this, _tabla);
|
|
125
|
+
__privateSet(this, _tabla, tabla);
|
|
126
|
+
__privateSet(this, _condicion, "");
|
|
127
|
+
this.conexion = conexion;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param {string} condicion -- condicional de tabla
|
|
132
|
+
* @example
|
|
133
|
+
* DB.Delete(tabla).WHERE(eq(valor,valor))
|
|
134
|
+
* DB.Delete(tabla).WHERE(AND(eq(valor,valor), eq(valor2,valor2)))
|
|
135
|
+
*/
|
|
136
|
+
where(condicion) {
|
|
137
|
+
if (!condicion || typeof condicion !== "string") {
|
|
138
|
+
throw new Error("La tabla es un campo obligatorio");
|
|
139
|
+
}
|
|
140
|
+
__privateSet(this, _condicion, ` where ${condicion}`);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
async execute() {
|
|
144
|
+
const query = `DELETE FROM ${__privateGet(this, _tabla)} ${__privateGet(this, _condicion)}`;
|
|
145
|
+
const respuesta = await this.conexion.executeConsulta({
|
|
146
|
+
query,
|
|
147
|
+
mensaje: "Ocurrio un error al momento de eliminar un dato"
|
|
148
|
+
});
|
|
149
|
+
return respuesta.affectedRows;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
_condicion = new WeakMap();
|
|
153
|
+
_tabla = new WeakMap();
|
|
154
|
+
|
|
155
|
+
// conection/middleware/insertar.ts
|
|
156
|
+
var QueryBuilder = class {
|
|
157
|
+
/**
|
|
158
|
+
* @throws {Error} Si la consulta es vacía.
|
|
159
|
+
*/
|
|
160
|
+
/**
|
|
161
|
+
* @param {string[]} parametros - campo obligatorio
|
|
162
|
+
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
163
|
+
* @param {string[]} values - campo obligatorio
|
|
164
|
+
*/
|
|
165
|
+
constructor(conexion, tabla, parametros) {
|
|
166
|
+
if (!parametros || !Array.isArray(parametros)) {
|
|
167
|
+
throw new Error(`campos obligatorios`);
|
|
168
|
+
}
|
|
169
|
+
if (!tabla || typeof tabla !== "string") {
|
|
170
|
+
throw new Error("Nombre tabla obligatorio");
|
|
171
|
+
}
|
|
172
|
+
this.tabla = tabla;
|
|
173
|
+
this.parametros = parametros;
|
|
174
|
+
this.valores = [];
|
|
175
|
+
this.valorRetorno = null;
|
|
176
|
+
this.conexion = conexion;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
*
|
|
180
|
+
* @param {arrayData | arrayDatas} values
|
|
181
|
+
* @example
|
|
182
|
+
* //para un salo dato
|
|
183
|
+
* ['dato1','dato2']
|
|
184
|
+
* //para varios datos
|
|
185
|
+
* [['dato1','dato1/2'],['dato2','dato2/2']]
|
|
186
|
+
*
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
Values(values) {
|
|
190
|
+
if (!values || !Array.isArray(values)) {
|
|
191
|
+
throw new Error("los valores tienen que ser tipo array");
|
|
192
|
+
}
|
|
193
|
+
this.valores = values;
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
async execute() {
|
|
197
|
+
this.valorRetorno = 1;
|
|
198
|
+
let query1 = `INSERT INTO ${this.tabla} `;
|
|
199
|
+
let param = "";
|
|
200
|
+
let arrayArrays = false;
|
|
201
|
+
let paramespaces = "";
|
|
202
|
+
if (typeof this.parametros !== "string") {
|
|
203
|
+
if (Array.isArray(this.valores)) arrayArrays = true;
|
|
204
|
+
this.parametros.forEach((valor, index) => {
|
|
205
|
+
param += valor;
|
|
206
|
+
paramespaces += ` ? `;
|
|
207
|
+
if (index < this.parametros.length - 1) {
|
|
208
|
+
param += ", ";
|
|
209
|
+
paramespaces += ", ";
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
let query = `${query1} (${param}) VALUES `;
|
|
214
|
+
if (arrayArrays) {
|
|
215
|
+
query += ` ? `;
|
|
216
|
+
} else {
|
|
217
|
+
query += `(${paramespaces})`;
|
|
218
|
+
}
|
|
219
|
+
const respuesta = await this.conexion.executeConsulta({
|
|
220
|
+
query,
|
|
221
|
+
valores: this.valores,
|
|
222
|
+
mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
|
|
223
|
+
});
|
|
224
|
+
return respuesta.insertId;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// conection/middleware/select.ts
|
|
229
|
+
var Select = class {
|
|
230
|
+
/**
|
|
231
|
+
* @param {string[]} parametros - campo obligatorio
|
|
232
|
+
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
233
|
+
* @param {string[]} values - campo obligatorio
|
|
234
|
+
* @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
|
|
235
|
+
*/
|
|
236
|
+
constructor(conexion, parametros = "*") {
|
|
237
|
+
this.conexion = conexion;
|
|
238
|
+
this.valores = !Array.isArray(parametros) ? false : true;
|
|
239
|
+
this.parametros = parametros;
|
|
240
|
+
this.tabla = void 0;
|
|
241
|
+
this.innerJoin = "";
|
|
242
|
+
this.leftjoins = "";
|
|
243
|
+
this.rigthjoins = "";
|
|
244
|
+
this.limit = "";
|
|
245
|
+
this.condicion = "";
|
|
246
|
+
this.orderBy = "";
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
250
|
+
*/
|
|
251
|
+
from(tabla) {
|
|
252
|
+
if (!tabla || typeof tabla !== "string") {
|
|
253
|
+
throw new Error("La tabla es un campo obligatorio");
|
|
254
|
+
}
|
|
255
|
+
this.tabla = tabla;
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
innerJOIN(tabla, condition) {
|
|
259
|
+
if (!tabla || typeof tabla !== "string") {
|
|
260
|
+
throw new Error("La tabla es un campo obligatorio");
|
|
261
|
+
}
|
|
262
|
+
this.innerJoin += ` INNER JOIN ${tabla} ON ${condition}`;
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
leftJoin(tabla, condition) {
|
|
266
|
+
if (!tabla || typeof tabla !== "string") {
|
|
267
|
+
throw new Error("La tabla es un campo obligatorio");
|
|
268
|
+
}
|
|
269
|
+
this.leftjoins += ` LEFT JOIN ${tabla} ON ${condition}`;
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
rigthJoin(tabla, condition) {
|
|
273
|
+
if (!tabla || typeof tabla !== "string") {
|
|
274
|
+
throw new Error("La tabla es un campo obligatorio");
|
|
275
|
+
}
|
|
276
|
+
this.rigthjoins += ` RIGHT JOIN ${tabla} ON ${condition}`;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
|
|
281
|
+
*/
|
|
282
|
+
where(condition = void 0) {
|
|
283
|
+
if (condition === void 0 || !condition) {
|
|
284
|
+
this.condicion = "";
|
|
285
|
+
} else {
|
|
286
|
+
if (this.condicion.length < 2) {
|
|
287
|
+
this.condicion += `WHERE `;
|
|
288
|
+
}
|
|
289
|
+
this.condicion += ` ${condition}`;
|
|
290
|
+
}
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* @typedef { "ASC" | "DESC" } tipos
|
|
295
|
+
*/
|
|
296
|
+
/**
|
|
297
|
+
*
|
|
298
|
+
* @param {{
|
|
299
|
+
* [clave:string]:tipos
|
|
300
|
+
* }} objeto --Filtrado
|
|
301
|
+
* @example
|
|
302
|
+
* select().orderBy({nombre:'DESC',id:'ASC'});
|
|
303
|
+
*/
|
|
304
|
+
OrderBy(objeto) {
|
|
305
|
+
if (typeof objeto !== "object")
|
|
306
|
+
throw new Error("Solo se permite objetos , error de OrderBy");
|
|
307
|
+
if (Object.keys(objeto).length === 0)
|
|
308
|
+
throw new Error("No se permite los campos vacios");
|
|
309
|
+
this.orderBy = " ORDER BY ";
|
|
310
|
+
for (const [clave, valor] of Object.entries(objeto)) {
|
|
311
|
+
if (valor !== "ASC" && valor !== "DESC")
|
|
312
|
+
throw new Error("ASC o DESC requerido para la consulta");
|
|
313
|
+
this.orderBy += ` ${clave} ${valor},`;
|
|
314
|
+
}
|
|
315
|
+
this.orderBy = this.orderBy.slice(0, -1);
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
*
|
|
320
|
+
* @param {Number} cantidad
|
|
321
|
+
*/
|
|
322
|
+
LIMIT(cantidad = 1) {
|
|
323
|
+
if (typeof cantidad != "number") {
|
|
324
|
+
throw new Error("Cantidad tiene que ser un numero");
|
|
325
|
+
}
|
|
326
|
+
this.limit = `LIMIT ${cantidad}`;
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
*
|
|
331
|
+
* @param {String} texto
|
|
332
|
+
*/
|
|
333
|
+
/**
|
|
334
|
+
* @returns {Promise<Array<Object>>}
|
|
335
|
+
*/
|
|
336
|
+
async execute() {
|
|
337
|
+
let selectFields = "*";
|
|
338
|
+
if (this.valores) {
|
|
339
|
+
if (typeof this.parametros !== "undefined" && typeof this.parametros !== "string") {
|
|
340
|
+
selectFields = this.parametros.join(",");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const query = `SELECT ${selectFields} from ${this.tabla} ${this.innerJoin} ${this.leftjoins} ${this.rigthjoins} ${this.condicion} ${this.orderBy} ${this.limit};`;
|
|
344
|
+
const respuesta = await this.conexion.executeConsulta({
|
|
345
|
+
query,
|
|
346
|
+
mensaje: "Ocurrio un error realizar un select"
|
|
347
|
+
});
|
|
348
|
+
return respuesta;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// conection/middleware/condicionals.ts
|
|
353
|
+
var AND = (...valor1) => {
|
|
354
|
+
const separacion = valor1.join(" and ");
|
|
355
|
+
return `(${separacion})`;
|
|
356
|
+
};
|
|
357
|
+
var OR = (...valor1) => {
|
|
358
|
+
const separadosComas = valor1.join(" or ");
|
|
359
|
+
return `(${separadosComas})`;
|
|
360
|
+
};
|
|
361
|
+
var ORQ = (condicion1, ...condicionals) => {
|
|
362
|
+
const data2 = condicionals.map((dato) => {
|
|
363
|
+
if (typeof dato == "number" || typeof dato == "boolean") return ` '${condicion1}' = ${dato}`;
|
|
364
|
+
return ` '${condicion1}' = '${dato}' `;
|
|
365
|
+
});
|
|
366
|
+
const separador = data2.join(" or ");
|
|
367
|
+
return separador;
|
|
368
|
+
};
|
|
369
|
+
var ILIKE = (valor1, valor2) => {
|
|
370
|
+
return `${valor1} ILIKE '%${valor2}%'`;
|
|
371
|
+
};
|
|
372
|
+
var now = (variable, diasTrancurridos, minor = true) => {
|
|
373
|
+
if (typeof variable !== "string") {
|
|
374
|
+
throw new Error("Variable no valida");
|
|
375
|
+
}
|
|
376
|
+
if (typeof diasTrancurridos !== "number") {
|
|
377
|
+
throw new Error("dias Transcurridos no valido");
|
|
378
|
+
}
|
|
379
|
+
if (minor) {
|
|
380
|
+
return `( ${variable} < NOW() - INTERVAL '${diasTrancurridos} days')`;
|
|
381
|
+
}
|
|
382
|
+
return `( ${variable} > NOW() - INTERVAL '${diasTrancurridos} days')`;
|
|
383
|
+
};
|
|
384
|
+
var NULL = (variable) => {
|
|
385
|
+
return `${variable} IS NULL`;
|
|
386
|
+
};
|
|
387
|
+
var NOTNULL = (variable) => {
|
|
388
|
+
return `${variable} IS NOT NULL`;
|
|
389
|
+
};
|
|
390
|
+
var eq = (valor1, valor2, literal = true) => {
|
|
391
|
+
if (typeof valor1 === "string") valor1 = valor1.trim();
|
|
392
|
+
if (typeof valor2 === "string") valor2 = valor2.trim();
|
|
393
|
+
if (!literal) {
|
|
394
|
+
return `${valor1} = ${valor2}`;
|
|
395
|
+
}
|
|
396
|
+
return `${valor1} = '${valor2}'`;
|
|
397
|
+
};
|
|
398
|
+
var mayor = (valor, valor2) => {
|
|
399
|
+
return ` ${valor} > ${valor2} `;
|
|
400
|
+
};
|
|
401
|
+
var menor = (valor, valor2) => {
|
|
402
|
+
return ` ${valor} < ${valor2} `;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// conection/middleware/update.ts
|
|
406
|
+
var Update = class {
|
|
407
|
+
/**
|
|
408
|
+
* @param {string} nombreTabla - nombre de la tabla a actualizar
|
|
409
|
+
*/
|
|
410
|
+
constructor(conexion, nombreTabla) {
|
|
411
|
+
this.nombreTabla = "";
|
|
412
|
+
this.valores = "";
|
|
413
|
+
this.condicion = "";
|
|
414
|
+
if (typeof nombreTabla !== "string") {
|
|
415
|
+
throw new Error("el valor ingresado requiere un string");
|
|
416
|
+
}
|
|
417
|
+
if (nombreTabla === void 0 || !nombreTabla) {
|
|
418
|
+
throw new Error("El nombre de la tabla es requerido");
|
|
419
|
+
}
|
|
420
|
+
this.nombreTabla = nombreTabla;
|
|
421
|
+
this.conexion = conexion;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @param {Valores} valores - valores a actualizar
|
|
425
|
+
* @example
|
|
426
|
+
* .set({'campo1':'valor1', 'campo2':'valor2'})
|
|
427
|
+
*/
|
|
428
|
+
set(valores) {
|
|
429
|
+
if (typeof valores !== "object") {
|
|
430
|
+
throw new Error("es requerido un objeto");
|
|
431
|
+
}
|
|
432
|
+
let valor = "";
|
|
433
|
+
for (const key in valores) {
|
|
434
|
+
if (valores.hasOwnProperty(key)) {
|
|
435
|
+
const value = valores[key];
|
|
436
|
+
if (value === void 0) continue;
|
|
437
|
+
valor += eq(key, value);
|
|
438
|
+
valor += ",";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
valor = valor.slice(0, -1);
|
|
442
|
+
this.valores = valor;
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @param {string} condicion - valor condicional
|
|
447
|
+
* @example
|
|
448
|
+
* //para completar una condicional puedes usar
|
|
449
|
+
* where(eq())
|
|
450
|
+
* where(AND())
|
|
451
|
+
* where(OR())
|
|
452
|
+
* where(ORQ())
|
|
453
|
+
*/
|
|
454
|
+
where(condicion) {
|
|
455
|
+
if (condicion === void 0 || !condicion) {
|
|
456
|
+
this.condicion = "";
|
|
457
|
+
} else {
|
|
458
|
+
if (this.condicion.length < 2) {
|
|
459
|
+
this.condicion += `WHERE `;
|
|
460
|
+
}
|
|
461
|
+
this.condicion += `${condicion}`;
|
|
462
|
+
}
|
|
463
|
+
return this;
|
|
464
|
+
}
|
|
465
|
+
async execute() {
|
|
466
|
+
const query = `UPDATE ${this.nombreTabla} SET ${this.valores} ${this.condicion};`;
|
|
467
|
+
const respuesta = await this.conexion.executeConsulta({
|
|
468
|
+
query,
|
|
469
|
+
mensaje: "Error Update"
|
|
470
|
+
});
|
|
471
|
+
if (this.conexion.tipo === "mysql") {
|
|
472
|
+
return respuesta;
|
|
473
|
+
} else {
|
|
474
|
+
return {
|
|
475
|
+
resultado: respuesta.rows.info,
|
|
476
|
+
filasAfectadas: respuesta.rows.affectedRows
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// conection/conexion.ts
|
|
483
|
+
var DB = class {
|
|
484
|
+
/**
|
|
485
|
+
* @param {string} tabla - campo obligatorio
|
|
486
|
+
* @param {string[]} parametros - campo obligatorio
|
|
487
|
+
* @example
|
|
488
|
+
* DB.Insert('tabla',['campo1','campo2'])
|
|
489
|
+
*/
|
|
490
|
+
static Insert(tabla, parametros) {
|
|
491
|
+
const conex = getRed();
|
|
492
|
+
return new QueryBuilder(conex, tabla, parametros);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* @param {string[]} parametros - campo opcional
|
|
496
|
+
*/
|
|
497
|
+
static select(parametros) {
|
|
498
|
+
const conex = getRed();
|
|
499
|
+
return new Select(conex, parametros);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* @param {string} nombreTabla - nombre de la tabla a actualizar
|
|
503
|
+
*/
|
|
504
|
+
static update(nombreTabla) {
|
|
505
|
+
const conex = getRed();
|
|
506
|
+
return new Update(conex, nombreTabla);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param {string} nombreTabla -- tabla a eliminar
|
|
511
|
+
* @example
|
|
512
|
+
* delete from tabla
|
|
513
|
+
*/
|
|
514
|
+
static Delete(nombreTabla) {
|
|
515
|
+
const conex = getRed();
|
|
516
|
+
return new DeleteR(conex, nombreTabla);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
export {
|
|
520
|
+
AND,
|
|
521
|
+
BDconnection,
|
|
522
|
+
DB,
|
|
523
|
+
DeleteR,
|
|
524
|
+
ILIKE,
|
|
525
|
+
NOTNULL,
|
|
526
|
+
NULL,
|
|
527
|
+
OR,
|
|
528
|
+
ORQ,
|
|
529
|
+
QueryBuilder,
|
|
530
|
+
Select,
|
|
531
|
+
Update,
|
|
532
|
+
eq,
|
|
533
|
+
getConexion,
|
|
534
|
+
getRed,
|
|
535
|
+
mayor,
|
|
536
|
+
menor,
|
|
537
|
+
now
|
|
538
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zormz",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
"type": "module",
|
|
20
|
+
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "ts-node index.ts"
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"mysql": "*",
|
|
33
|
+
"pg": "*"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"pg": { "optional": true },
|
|
37
|
+
"mysql": { "optional": true }
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"mysql2": "^3.15.3"
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"ts-node": "^10.9.2",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"@types/node": "^24.10.1",
|
|
48
|
+
"tsup": "^8.5.1"
|
|
49
|
+
}
|
|
50
|
+
}
|