zormz 1.5.0 → 1.6.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 +208 -4
- package/dist/index.d.mts +108 -4
- package/dist/index.d.ts +108 -4
- package/dist/index.js +68 -5
- package/dist/index.mjs +62 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -364,7 +364,212 @@ MENOR('edad', 18)
|
|
|
364
364
|
```
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Complementos de Select (Funciones agregadas SQL)
|
|
370
|
+
|
|
371
|
+
Este módulo proporciona **funciones auxiliares** para facilitar el uso de funciones agregadas SQL dentro de tu sistema de consultas usando `DB.Select()`.
|
|
372
|
+
|
|
373
|
+
Actualmente incluye soporte para:
|
|
374
|
+
|
|
375
|
+
* AVG
|
|
376
|
+
* COUNT
|
|
377
|
+
* MIN
|
|
378
|
+
* MAX
|
|
379
|
+
|
|
380
|
+
Estas funciones permiten generar expresiones SQL limpias, reutilizables y tipadas desde TypeScript.
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
# Uso general
|
|
387
|
+
|
|
388
|
+
Todas las funciones reciben:
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
(nombreColumna, aliasOpcional)
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Donde:
|
|
395
|
+
|
|
396
|
+
| Parámetro | Tipo | Descripción |
|
|
397
|
+
| --------- | ----------------- | ---------------------------------- |
|
|
398
|
+
| columna | string | Nombre de la columna de la tabla |
|
|
399
|
+
| alias | string (opcional) | Nombre personalizado del resultado |
|
|
400
|
+
|
|
401
|
+
Retornan:
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
string
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Lista para ser usada dentro de `DB.Select()`.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
# Funciones disponibles
|
|
412
|
+
|
|
413
|
+
## AVG()
|
|
414
|
+
|
|
415
|
+
Calcula el promedio de una columna.
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
const [resultado] = await DB.Select([
|
|
419
|
+
AVG(usuarios.iduser, "promedio")
|
|
420
|
+
])
|
|
421
|
+
.from(usuarios())
|
|
422
|
+
.execute();
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Resultado:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
{ promedio: '4.0000000000000000' }
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## COUNT()
|
|
434
|
+
|
|
435
|
+
Cuenta la cantidad de registros.
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
const datos = await DB.Select([
|
|
439
|
+
COUNT(usuarios.iduser, "cantidad")
|
|
440
|
+
])
|
|
441
|
+
.from(usuarios())
|
|
442
|
+
.execute();
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Resultado:
|
|
446
|
+
|
|
447
|
+
```ts
|
|
448
|
+
[ { cantidad: 9 } ]
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## MIN()
|
|
454
|
+
|
|
455
|
+
Obtiene el valor mínimo de una columna.
|
|
456
|
+
|
|
457
|
+
```ts
|
|
458
|
+
const datos = await DB.Select([
|
|
459
|
+
MIN(usuarios.iduser, "minimo")
|
|
460
|
+
])
|
|
461
|
+
.from(usuarios())
|
|
462
|
+
.execute();
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Resultado:
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
[ { minimo: 1 } ]
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## MAX()
|
|
474
|
+
|
|
475
|
+
Obtiene el valor máximo de una columna.
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
const [datos] = await DB.Select([
|
|
479
|
+
MAX(usuarios.iduser, "maximo")
|
|
480
|
+
])
|
|
481
|
+
.from(usuarios())
|
|
482
|
+
.execute();
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Resultado:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
{ maximo: 7 }
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
# Alias (pseudoNombre)
|
|
494
|
+
|
|
495
|
+
El segundo parámetro permite definir el nombre del campo retornado:
|
|
496
|
+
|
|
497
|
+
```ts
|
|
498
|
+
AVG("usuarios.edad", "edad_promedio")
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Genera internamente:
|
|
502
|
+
|
|
503
|
+
```sql
|
|
504
|
+
AVG(usuarios.edad) AS edad_promedio
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
Si no se especifica alias:
|
|
508
|
+
|
|
509
|
+
```ts
|
|
510
|
+
AVG("usuarios.edad")
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Genera:
|
|
514
|
+
|
|
515
|
+
```sql
|
|
516
|
+
AVG(usuarios.edad)
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
# Ejemplo completo
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
const resultado = await DB.Select([
|
|
525
|
+
COUNT(usuarios.iduser, "total"),
|
|
526
|
+
MAX(usuarios.iduser, "mayor"),
|
|
527
|
+
MIN(usuarios.iduser, "menor"),
|
|
528
|
+
AVG(usuarios.iduser, "promedio")
|
|
529
|
+
])
|
|
530
|
+
.from(usuarios())
|
|
531
|
+
.execute();
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
Resultado:
|
|
535
|
+
|
|
536
|
+
```ts
|
|
537
|
+
[
|
|
538
|
+
{
|
|
539
|
+
total: 9,
|
|
540
|
+
mayor: 7,
|
|
541
|
+
menor: 1,
|
|
542
|
+
promedio: "4.0000000000000000"
|
|
543
|
+
}
|
|
544
|
+
]
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
# Objetivo del módulo
|
|
550
|
+
|
|
551
|
+
Este módulo existe para:
|
|
552
|
+
|
|
553
|
+
* Evitar escribir SQL manual repetitivo
|
|
554
|
+
* Mejorar legibilidad del código
|
|
555
|
+
* Mantener consistencia en alias
|
|
556
|
+
* Facilitar composición de consultas dinámicas
|
|
557
|
+
* Integrarse naturalmente con `DB.Select()`
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
# Próximas mejoras sugeridas
|
|
562
|
+
|
|
563
|
+
Puedes ampliar fácilmente el módulo agregando:
|
|
564
|
+
|
|
565
|
+
* SUM()
|
|
566
|
+
* ROUND()
|
|
567
|
+
|
|
568
|
+
Siguiendo exactamente el mismo patrón usado aquí.
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## Ejemplo de Uso ZORMZ
|
|
368
573
|
|
|
369
574
|
```ts
|
|
370
575
|
import {
|
|
@@ -429,9 +634,8 @@ pruebaData().catch(console.error);
|
|
|
429
634
|
- ORM en version inicial con enfoque de tipado y autompletado
|
|
430
635
|
- Compatible con **MYSQL** y **PG**
|
|
431
636
|
- Preparado para extenderse
|
|
432
|
-
- Las versiones +1.
|
|
433
|
-
- version estable 1.
|
|
434
|
-
- Se corrigio la compatiblidad de PG al momento de realizar Insert :c losiento
|
|
637
|
+
- Las versiones +1.5.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
|
|
638
|
+
- version estable 1.5.0
|
|
435
639
|
|
|
436
640
|
## Licencia
|
|
437
641
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
interface ResultSetHeaderMysql {
|
|
2
|
+
fieldCount: number;
|
|
3
|
+
affectedRows: number;
|
|
4
|
+
insertId: number;
|
|
5
|
+
info: string;
|
|
6
|
+
serverStatus: number;
|
|
7
|
+
warningStatus: number;
|
|
8
|
+
changedRows: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ResultPG {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
command?: "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "DDL" | "DROP";
|
|
14
|
+
rowCount: number | null;
|
|
15
|
+
oid?: number | null;
|
|
16
|
+
rows?: any[];
|
|
17
|
+
fields?: any[];
|
|
18
|
+
rowAsArray?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
type ColumnTypes =
|
|
2
22
|
| "varchar"
|
|
3
23
|
| "int"
|
|
@@ -36,6 +56,13 @@ interface UpdateParams {
|
|
|
36
56
|
campoUp: string;
|
|
37
57
|
newCampoUp: string;
|
|
38
58
|
dataTable?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
interface roundInd {
|
|
63
|
+
columna: string;
|
|
64
|
+
decimales: number;
|
|
65
|
+
pseudonombre?: string;
|
|
39
66
|
}
|
|
40
67
|
|
|
41
68
|
interface connecionLocal {
|
|
@@ -62,7 +89,7 @@ declare class BDconnection {
|
|
|
62
89
|
constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
|
|
63
90
|
private conexionMysql;
|
|
64
91
|
private connectionPG;
|
|
65
|
-
executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<any>;
|
|
92
|
+
executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<ResultPG | ResultSetHeaderMysql | any>;
|
|
66
93
|
}
|
|
67
94
|
declare function getTipoConexion(): connectionDB;
|
|
68
95
|
/**
|
|
@@ -140,7 +167,7 @@ declare class QueryBuilder {
|
|
|
140
167
|
*
|
|
141
168
|
* @param {arrayData | arrayDatas} values
|
|
142
169
|
* @example
|
|
143
|
-
* //para un
|
|
170
|
+
* //para un solo dato
|
|
144
171
|
* ['dato1','dato2']
|
|
145
172
|
* //para varios datos
|
|
146
173
|
* [['dato1','dato1/2'],['dato2','dato2/2']]
|
|
@@ -209,7 +236,7 @@ declare class Select {
|
|
|
209
236
|
/**
|
|
210
237
|
* @returns {Promise<Array<Object>>}
|
|
211
238
|
*/
|
|
212
|
-
execute(see?: boolean): Promise<any[]
|
|
239
|
+
execute(see?: boolean): Promise<any[]>;
|
|
213
240
|
}
|
|
214
241
|
|
|
215
242
|
type Valores = Record<string, string | number | undefined>;
|
|
@@ -500,4 +527,81 @@ declare class Money {
|
|
|
500
527
|
}
|
|
501
528
|
declare function money(presicion?: number, decimales?: number): Money;
|
|
502
529
|
|
|
503
|
-
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* @param {string} columna - campo de la tabla
|
|
533
|
+
* @param {string | undefined} pseudoNombre - nombre columna
|
|
534
|
+
* @return {string}
|
|
535
|
+
* @example
|
|
536
|
+
*
|
|
537
|
+
* const [promedio] = await DB.Select([AVG(usuarios.iduser, "promedio")])
|
|
538
|
+
.from(usuarios())
|
|
539
|
+
.execute();
|
|
540
|
+
* =>{ promedio: '4.0000000000000000' }
|
|
541
|
+
*/
|
|
542
|
+
declare const AVG: (columna: string, pseudoNombre?: string) => string;
|
|
543
|
+
/**
|
|
544
|
+
*
|
|
545
|
+
* @param {string} columna
|
|
546
|
+
* @param {string} pseudonombre
|
|
547
|
+
* @returns {string}
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* COUNT(usuarios.iduser,"primero")
|
|
551
|
+
* //uso
|
|
552
|
+
* await DB.Select([COUNT(usuarios.iduser,"cantidad")]).from(usuarios()).execute();
|
|
553
|
+
* => [ { cantidad: 9 } ]
|
|
554
|
+
*/
|
|
555
|
+
declare const COUNT: (columna: string, pseudonombre?: string) => string;
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
558
|
+
* @param {string} columna
|
|
559
|
+
* @param {string} pseudonombre
|
|
560
|
+
* @returns {string}
|
|
561
|
+
* @example
|
|
562
|
+
*
|
|
563
|
+
* MIN(usuarios.iduser,"primero")
|
|
564
|
+
* //uso
|
|
565
|
+
* await DB.Select([MIN(usuarios.iduser,"minimo")]).from(usuarios()).execute();
|
|
566
|
+
* => [ { minimo: 1 } ]
|
|
567
|
+
*/
|
|
568
|
+
declare const MIN: (columna: string, pseudonombre?: string) => string;
|
|
569
|
+
/**
|
|
570
|
+
*
|
|
571
|
+
* @param {string} columna
|
|
572
|
+
* @param {string} pseudonombre
|
|
573
|
+
* @returns {string}
|
|
574
|
+
* @example
|
|
575
|
+
*
|
|
576
|
+
* MAX(usuarios.iduser,"primero")
|
|
577
|
+
* //uso
|
|
578
|
+
* const [datos2] = await DB.Select([MAX(usuarios.iduser,"maximo")]).from(usuarios()).execute();
|
|
579
|
+
* => { maximo: 7 }
|
|
580
|
+
*/
|
|
581
|
+
declare const MAX: (columna: string, pseudonombre?: string) => string;
|
|
582
|
+
/**
|
|
583
|
+
*
|
|
584
|
+
* @param {string} columna
|
|
585
|
+
* @param {string} pseudonombre
|
|
586
|
+
* @returns {string}
|
|
587
|
+
* @example
|
|
588
|
+
*
|
|
589
|
+
* SUM(usuarios.iduser,"primero")
|
|
590
|
+
* //uso
|
|
591
|
+
* const [datos2] = await DB.Select([SUM(usuarios.iduser,"suma")]).from(usuarios()).execute();
|
|
592
|
+
* => { suma: 12 }
|
|
593
|
+
*/
|
|
594
|
+
declare const SUM: (columna: string, pseudonombre?: string) => string;
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
* @param {roundInd} param
|
|
598
|
+
* @returns
|
|
599
|
+
* *
|
|
600
|
+
* ROUND(usuarios.dinero,2,"precioAlterado")
|
|
601
|
+
* //uso
|
|
602
|
+
* const [datos2] = await DB.Select([(usuarios.dinero,"precioalterado")]).from(usuarios()).execute();
|
|
603
|
+
* => { precioalterado: 12.22}
|
|
604
|
+
*/
|
|
605
|
+
declare const ROUND: ({ columna, decimales, pseudonombre }: roundInd) => string;
|
|
606
|
+
|
|
607
|
+
export { AND, ANDD, AVG, BDconnection, COUNT, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAX, MAYOR, MENOR, MIN, NOTNULL, NOW, NULL, OR, ORD, ORQ, ORQD, QueryBuilder, ROUND, SUM, Select, type TableProxy, type Tipos, UP, Update, type Valores, type arrayData, type arrayDatas, bool, type connecionLocal, type connecionRed, type connectionDB, defineTable, dropTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, neq, timestamp, type valor, varchar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
interface ResultSetHeaderMysql {
|
|
2
|
+
fieldCount: number;
|
|
3
|
+
affectedRows: number;
|
|
4
|
+
insertId: number;
|
|
5
|
+
info: string;
|
|
6
|
+
serverStatus: number;
|
|
7
|
+
warningStatus: number;
|
|
8
|
+
changedRows: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ResultPG {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
command?: "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "DDL" | "DROP";
|
|
14
|
+
rowCount: number | null;
|
|
15
|
+
oid?: number | null;
|
|
16
|
+
rows?: any[];
|
|
17
|
+
fields?: any[];
|
|
18
|
+
rowAsArray?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
type ColumnTypes =
|
|
2
22
|
| "varchar"
|
|
3
23
|
| "int"
|
|
@@ -36,6 +56,13 @@ interface UpdateParams {
|
|
|
36
56
|
campoUp: string;
|
|
37
57
|
newCampoUp: string;
|
|
38
58
|
dataTable?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
interface roundInd {
|
|
63
|
+
columna: string;
|
|
64
|
+
decimales: number;
|
|
65
|
+
pseudonombre?: string;
|
|
39
66
|
}
|
|
40
67
|
|
|
41
68
|
interface connecionLocal {
|
|
@@ -62,7 +89,7 @@ declare class BDconnection {
|
|
|
62
89
|
constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
|
|
63
90
|
private conexionMysql;
|
|
64
91
|
private connectionPG;
|
|
65
|
-
executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<any>;
|
|
92
|
+
executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<ResultPG | ResultSetHeaderMysql | any>;
|
|
66
93
|
}
|
|
67
94
|
declare function getTipoConexion(): connectionDB;
|
|
68
95
|
/**
|
|
@@ -140,7 +167,7 @@ declare class QueryBuilder {
|
|
|
140
167
|
*
|
|
141
168
|
* @param {arrayData | arrayDatas} values
|
|
142
169
|
* @example
|
|
143
|
-
* //para un
|
|
170
|
+
* //para un solo dato
|
|
144
171
|
* ['dato1','dato2']
|
|
145
172
|
* //para varios datos
|
|
146
173
|
* [['dato1','dato1/2'],['dato2','dato2/2']]
|
|
@@ -209,7 +236,7 @@ declare class Select {
|
|
|
209
236
|
/**
|
|
210
237
|
* @returns {Promise<Array<Object>>}
|
|
211
238
|
*/
|
|
212
|
-
execute(see?: boolean): Promise<any[]
|
|
239
|
+
execute(see?: boolean): Promise<any[]>;
|
|
213
240
|
}
|
|
214
241
|
|
|
215
242
|
type Valores = Record<string, string | number | undefined>;
|
|
@@ -500,4 +527,81 @@ declare class Money {
|
|
|
500
527
|
}
|
|
501
528
|
declare function money(presicion?: number, decimales?: number): Money;
|
|
502
529
|
|
|
503
|
-
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* @param {string} columna - campo de la tabla
|
|
533
|
+
* @param {string | undefined} pseudoNombre - nombre columna
|
|
534
|
+
* @return {string}
|
|
535
|
+
* @example
|
|
536
|
+
*
|
|
537
|
+
* const [promedio] = await DB.Select([AVG(usuarios.iduser, "promedio")])
|
|
538
|
+
.from(usuarios())
|
|
539
|
+
.execute();
|
|
540
|
+
* =>{ promedio: '4.0000000000000000' }
|
|
541
|
+
*/
|
|
542
|
+
declare const AVG: (columna: string, pseudoNombre?: string) => string;
|
|
543
|
+
/**
|
|
544
|
+
*
|
|
545
|
+
* @param {string} columna
|
|
546
|
+
* @param {string} pseudonombre
|
|
547
|
+
* @returns {string}
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* COUNT(usuarios.iduser,"primero")
|
|
551
|
+
* //uso
|
|
552
|
+
* await DB.Select([COUNT(usuarios.iduser,"cantidad")]).from(usuarios()).execute();
|
|
553
|
+
* => [ { cantidad: 9 } ]
|
|
554
|
+
*/
|
|
555
|
+
declare const COUNT: (columna: string, pseudonombre?: string) => string;
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
558
|
+
* @param {string} columna
|
|
559
|
+
* @param {string} pseudonombre
|
|
560
|
+
* @returns {string}
|
|
561
|
+
* @example
|
|
562
|
+
*
|
|
563
|
+
* MIN(usuarios.iduser,"primero")
|
|
564
|
+
* //uso
|
|
565
|
+
* await DB.Select([MIN(usuarios.iduser,"minimo")]).from(usuarios()).execute();
|
|
566
|
+
* => [ { minimo: 1 } ]
|
|
567
|
+
*/
|
|
568
|
+
declare const MIN: (columna: string, pseudonombre?: string) => string;
|
|
569
|
+
/**
|
|
570
|
+
*
|
|
571
|
+
* @param {string} columna
|
|
572
|
+
* @param {string} pseudonombre
|
|
573
|
+
* @returns {string}
|
|
574
|
+
* @example
|
|
575
|
+
*
|
|
576
|
+
* MAX(usuarios.iduser,"primero")
|
|
577
|
+
* //uso
|
|
578
|
+
* const [datos2] = await DB.Select([MAX(usuarios.iduser,"maximo")]).from(usuarios()).execute();
|
|
579
|
+
* => { maximo: 7 }
|
|
580
|
+
*/
|
|
581
|
+
declare const MAX: (columna: string, pseudonombre?: string) => string;
|
|
582
|
+
/**
|
|
583
|
+
*
|
|
584
|
+
* @param {string} columna
|
|
585
|
+
* @param {string} pseudonombre
|
|
586
|
+
* @returns {string}
|
|
587
|
+
* @example
|
|
588
|
+
*
|
|
589
|
+
* SUM(usuarios.iduser,"primero")
|
|
590
|
+
* //uso
|
|
591
|
+
* const [datos2] = await DB.Select([SUM(usuarios.iduser,"suma")]).from(usuarios()).execute();
|
|
592
|
+
* => { suma: 12 }
|
|
593
|
+
*/
|
|
594
|
+
declare const SUM: (columna: string, pseudonombre?: string) => string;
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
* @param {roundInd} param
|
|
598
|
+
* @returns
|
|
599
|
+
* *
|
|
600
|
+
* ROUND(usuarios.dinero,2,"precioAlterado")
|
|
601
|
+
* //uso
|
|
602
|
+
* const [datos2] = await DB.Select([(usuarios.dinero,"precioalterado")]).from(usuarios()).execute();
|
|
603
|
+
* => { precioalterado: 12.22}
|
|
604
|
+
*/
|
|
605
|
+
declare const ROUND: ({ columna, decimales, pseudonombre }: roundInd) => string;
|
|
606
|
+
|
|
607
|
+
export { AND, ANDD, AVG, BDconnection, COUNT, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAX, MAYOR, MENOR, MIN, NOTNULL, NOW, NULL, OR, ORD, ORQ, ORQD, QueryBuilder, ROUND, SUM, Select, type TableProxy, type Tipos, UP, Update, type Valores, type arrayData, type arrayDatas, bool, type connecionLocal, type connecionRed, type connectionDB, defineTable, dropTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, neq, timestamp, type valor, varchar };
|
package/dist/index.js
CHANGED
|
@@ -39,13 +39,17 @@ var index_exports = {};
|
|
|
39
39
|
__export(index_exports, {
|
|
40
40
|
AND: () => AND,
|
|
41
41
|
ANDD: () => ANDD,
|
|
42
|
+
AVG: () => AVG,
|
|
42
43
|
BDconnection: () => BDconnection,
|
|
44
|
+
COUNT: () => COUNT,
|
|
43
45
|
CURRENT_TIMESTAMP: () => CURRENT_TIMESTAMP,
|
|
44
46
|
DB: () => DB,
|
|
45
47
|
DeleteR: () => DeleteR,
|
|
46
48
|
ILIKE: () => ILIKE,
|
|
49
|
+
MAX: () => MAX,
|
|
47
50
|
MAYOR: () => MAYOR,
|
|
48
51
|
MENOR: () => MENOR,
|
|
52
|
+
MIN: () => MIN,
|
|
49
53
|
NOTNULL: () => NOTNULL,
|
|
50
54
|
NOW: () => NOW,
|
|
51
55
|
NULL: () => NULL,
|
|
@@ -54,6 +58,8 @@ __export(index_exports, {
|
|
|
54
58
|
ORQ: () => ORQ,
|
|
55
59
|
ORQD: () => ORQD,
|
|
56
60
|
QueryBuilder: () => QueryBuilder,
|
|
61
|
+
ROUND: () => ROUND,
|
|
62
|
+
SUM: () => SUM,
|
|
57
63
|
Select: () => Select,
|
|
58
64
|
UP: () => UP,
|
|
59
65
|
Update: () => Update,
|
|
@@ -174,18 +180,23 @@ var BDconnection = class {
|
|
|
174
180
|
}
|
|
175
181
|
const respuesta = await pool2.query(query2, valores);
|
|
176
182
|
if (!respuesta) {
|
|
177
|
-
throw new Error(`
|
|
183
|
+
throw new Error(` Fallo la consulta `);
|
|
178
184
|
}
|
|
179
185
|
return respuesta;
|
|
186
|
+
} else {
|
|
187
|
+
return [];
|
|
180
188
|
}
|
|
181
189
|
} catch (error) {
|
|
182
|
-
if (!alertar) return;
|
|
190
|
+
if (!alertar) return [];
|
|
183
191
|
if (typeof error === "object" && error !== null && "code" in error) {
|
|
184
192
|
if (error.code === "ETIMEDOUT") {
|
|
185
193
|
throw new Error(`Su red esta limitando el acceso`);
|
|
186
194
|
}
|
|
187
|
-
|
|
195
|
+
console.log(`${mensaje} : ${error} query ${query}`);
|
|
196
|
+
throw new Error(`data query invalid`);
|
|
188
197
|
}
|
|
198
|
+
console.error(error);
|
|
199
|
+
throw error;
|
|
189
200
|
}
|
|
190
201
|
}
|
|
191
202
|
};
|
|
@@ -357,7 +368,6 @@ async function dropTable(nombreTabla) {
|
|
|
357
368
|
mensaje: "Error al eliminar la tabla",
|
|
358
369
|
alertar: false
|
|
359
370
|
});
|
|
360
|
-
console.log(response);
|
|
361
371
|
if (response.command === "DROP") {
|
|
362
372
|
console.log(`\u{1F44D}\u{1F44D} Se elimino con exito la tabla ${nombreTabla} \u{1F44D}`);
|
|
363
373
|
return;
|
|
@@ -445,7 +455,7 @@ var QueryBuilder = class {
|
|
|
445
455
|
*
|
|
446
456
|
* @param {arrayData | arrayDatas} values
|
|
447
457
|
* @example
|
|
448
|
-
* //para un
|
|
458
|
+
* //para un solo dato
|
|
449
459
|
* ['dato1','dato2']
|
|
450
460
|
* //para varios datos
|
|
451
461
|
* [['dato1','dato1/2'],['dato2','dato2/2']]
|
|
@@ -681,7 +691,10 @@ var Select = class {
|
|
|
681
691
|
query,
|
|
682
692
|
mensaje: "Ocurrio un error realizar un select"
|
|
683
693
|
});
|
|
694
|
+
if (respuesta.rows === void 0) return [];
|
|
684
695
|
return respuesta.rows;
|
|
696
|
+
} else {
|
|
697
|
+
return [];
|
|
685
698
|
}
|
|
686
699
|
}
|
|
687
700
|
};
|
|
@@ -1209,17 +1222,65 @@ var Money = class {
|
|
|
1209
1222
|
function money(presicion = 10, decimales = 2) {
|
|
1210
1223
|
return new Money(presicion, decimales);
|
|
1211
1224
|
}
|
|
1225
|
+
|
|
1226
|
+
// conection/complements/selectComplement.ts
|
|
1227
|
+
var AVG = (columna, pseudoNombre) => {
|
|
1228
|
+
let valor = ` AVG(${columna}) `;
|
|
1229
|
+
if (pseudoNombre !== void 0) {
|
|
1230
|
+
valor += ` AS ${pseudoNombre} `;
|
|
1231
|
+
}
|
|
1232
|
+
return valor;
|
|
1233
|
+
};
|
|
1234
|
+
var COUNT = (columna, pseudonombre) => {
|
|
1235
|
+
let valor = ` COUNT(${columna}) `;
|
|
1236
|
+
if (pseudonombre !== void 0) {
|
|
1237
|
+
valor += ` AS ${pseudonombre} `;
|
|
1238
|
+
}
|
|
1239
|
+
return valor;
|
|
1240
|
+
};
|
|
1241
|
+
var MIN = (columna, pseudonombre) => {
|
|
1242
|
+
let valor = ` MIN(${columna}) `;
|
|
1243
|
+
if (pseudonombre !== void 0) {
|
|
1244
|
+
valor += ` AS ${pseudonombre} `;
|
|
1245
|
+
}
|
|
1246
|
+
return valor;
|
|
1247
|
+
};
|
|
1248
|
+
var MAX = (columna, pseudonombre) => {
|
|
1249
|
+
let valor = ` MAX(${columna}) `;
|
|
1250
|
+
if (pseudonombre !== void 0) {
|
|
1251
|
+
valor += ` AS ${pseudonombre} `;
|
|
1252
|
+
}
|
|
1253
|
+
return valor;
|
|
1254
|
+
};
|
|
1255
|
+
var SUM = (columna, pseudonombre) => {
|
|
1256
|
+
let valor = ` SUM(${columna}) `;
|
|
1257
|
+
if (pseudonombre !== void 0) {
|
|
1258
|
+
valor += ` AS ${pseudonombre} `;
|
|
1259
|
+
}
|
|
1260
|
+
return valor;
|
|
1261
|
+
};
|
|
1262
|
+
var ROUND = ({ columna, decimales = 2, pseudonombre }) => {
|
|
1263
|
+
let valor = ` ROUND(${columna},${decimales}) `;
|
|
1264
|
+
if (pseudonombre !== void 0) {
|
|
1265
|
+
valor += ` AS ${pseudonombre} `;
|
|
1266
|
+
}
|
|
1267
|
+
return valor;
|
|
1268
|
+
};
|
|
1212
1269
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1213
1270
|
0 && (module.exports = {
|
|
1214
1271
|
AND,
|
|
1215
1272
|
ANDD,
|
|
1273
|
+
AVG,
|
|
1216
1274
|
BDconnection,
|
|
1275
|
+
COUNT,
|
|
1217
1276
|
CURRENT_TIMESTAMP,
|
|
1218
1277
|
DB,
|
|
1219
1278
|
DeleteR,
|
|
1220
1279
|
ILIKE,
|
|
1280
|
+
MAX,
|
|
1221
1281
|
MAYOR,
|
|
1222
1282
|
MENOR,
|
|
1283
|
+
MIN,
|
|
1223
1284
|
NOTNULL,
|
|
1224
1285
|
NOW,
|
|
1225
1286
|
NULL,
|
|
@@ -1228,6 +1289,8 @@ function money(presicion = 10, decimales = 2) {
|
|
|
1228
1289
|
ORQ,
|
|
1229
1290
|
ORQD,
|
|
1230
1291
|
QueryBuilder,
|
|
1292
|
+
ROUND,
|
|
1293
|
+
SUM,
|
|
1231
1294
|
Select,
|
|
1232
1295
|
UP,
|
|
1233
1296
|
Update,
|
package/dist/index.mjs
CHANGED
|
@@ -107,18 +107,23 @@ var BDconnection = class {
|
|
|
107
107
|
}
|
|
108
108
|
const respuesta = await pool2.query(query2, valores);
|
|
109
109
|
if (!respuesta) {
|
|
110
|
-
throw new Error(`
|
|
110
|
+
throw new Error(` Fallo la consulta `);
|
|
111
111
|
}
|
|
112
112
|
return respuesta;
|
|
113
|
+
} else {
|
|
114
|
+
return [];
|
|
113
115
|
}
|
|
114
116
|
} catch (error) {
|
|
115
|
-
if (!alertar) return;
|
|
117
|
+
if (!alertar) return [];
|
|
116
118
|
if (typeof error === "object" && error !== null && "code" in error) {
|
|
117
119
|
if (error.code === "ETIMEDOUT") {
|
|
118
120
|
throw new Error(`Su red esta limitando el acceso`);
|
|
119
121
|
}
|
|
120
|
-
|
|
122
|
+
console.log(`${mensaje} : ${error} query ${query}`);
|
|
123
|
+
throw new Error(`data query invalid`);
|
|
121
124
|
}
|
|
125
|
+
console.error(error);
|
|
126
|
+
throw error;
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
};
|
|
@@ -290,7 +295,6 @@ async function dropTable(nombreTabla) {
|
|
|
290
295
|
mensaje: "Error al eliminar la tabla",
|
|
291
296
|
alertar: false
|
|
292
297
|
});
|
|
293
|
-
console.log(response);
|
|
294
298
|
if (response.command === "DROP") {
|
|
295
299
|
console.log(`\u{1F44D}\u{1F44D} Se elimino con exito la tabla ${nombreTabla} \u{1F44D}`);
|
|
296
300
|
return;
|
|
@@ -378,7 +382,7 @@ var QueryBuilder = class {
|
|
|
378
382
|
*
|
|
379
383
|
* @param {arrayData | arrayDatas} values
|
|
380
384
|
* @example
|
|
381
|
-
* //para un
|
|
385
|
+
* //para un solo dato
|
|
382
386
|
* ['dato1','dato2']
|
|
383
387
|
* //para varios datos
|
|
384
388
|
* [['dato1','dato1/2'],['dato2','dato2/2']]
|
|
@@ -614,7 +618,10 @@ var Select = class {
|
|
|
614
618
|
query,
|
|
615
619
|
mensaje: "Ocurrio un error realizar un select"
|
|
616
620
|
});
|
|
621
|
+
if (respuesta.rows === void 0) return [];
|
|
617
622
|
return respuesta.rows;
|
|
623
|
+
} else {
|
|
624
|
+
return [];
|
|
618
625
|
}
|
|
619
626
|
}
|
|
620
627
|
};
|
|
@@ -1142,16 +1149,64 @@ var Money = class {
|
|
|
1142
1149
|
function money(presicion = 10, decimales = 2) {
|
|
1143
1150
|
return new Money(presicion, decimales);
|
|
1144
1151
|
}
|
|
1152
|
+
|
|
1153
|
+
// conection/complements/selectComplement.ts
|
|
1154
|
+
var AVG = (columna, pseudoNombre) => {
|
|
1155
|
+
let valor = ` AVG(${columna}) `;
|
|
1156
|
+
if (pseudoNombre !== void 0) {
|
|
1157
|
+
valor += ` AS ${pseudoNombre} `;
|
|
1158
|
+
}
|
|
1159
|
+
return valor;
|
|
1160
|
+
};
|
|
1161
|
+
var COUNT = (columna, pseudonombre) => {
|
|
1162
|
+
let valor = ` COUNT(${columna}) `;
|
|
1163
|
+
if (pseudonombre !== void 0) {
|
|
1164
|
+
valor += ` AS ${pseudonombre} `;
|
|
1165
|
+
}
|
|
1166
|
+
return valor;
|
|
1167
|
+
};
|
|
1168
|
+
var MIN = (columna, pseudonombre) => {
|
|
1169
|
+
let valor = ` MIN(${columna}) `;
|
|
1170
|
+
if (pseudonombre !== void 0) {
|
|
1171
|
+
valor += ` AS ${pseudonombre} `;
|
|
1172
|
+
}
|
|
1173
|
+
return valor;
|
|
1174
|
+
};
|
|
1175
|
+
var MAX = (columna, pseudonombre) => {
|
|
1176
|
+
let valor = ` MAX(${columna}) `;
|
|
1177
|
+
if (pseudonombre !== void 0) {
|
|
1178
|
+
valor += ` AS ${pseudonombre} `;
|
|
1179
|
+
}
|
|
1180
|
+
return valor;
|
|
1181
|
+
};
|
|
1182
|
+
var SUM = (columna, pseudonombre) => {
|
|
1183
|
+
let valor = ` SUM(${columna}) `;
|
|
1184
|
+
if (pseudonombre !== void 0) {
|
|
1185
|
+
valor += ` AS ${pseudonombre} `;
|
|
1186
|
+
}
|
|
1187
|
+
return valor;
|
|
1188
|
+
};
|
|
1189
|
+
var ROUND = ({ columna, decimales = 2, pseudonombre }) => {
|
|
1190
|
+
let valor = ` ROUND(${columna},${decimales}) `;
|
|
1191
|
+
if (pseudonombre !== void 0) {
|
|
1192
|
+
valor += ` AS ${pseudonombre} `;
|
|
1193
|
+
}
|
|
1194
|
+
return valor;
|
|
1195
|
+
};
|
|
1145
1196
|
export {
|
|
1146
1197
|
AND,
|
|
1147
1198
|
ANDD,
|
|
1199
|
+
AVG,
|
|
1148
1200
|
BDconnection,
|
|
1201
|
+
COUNT,
|
|
1149
1202
|
CURRENT_TIMESTAMP,
|
|
1150
1203
|
DB,
|
|
1151
1204
|
DeleteR,
|
|
1152
1205
|
ILIKE,
|
|
1206
|
+
MAX,
|
|
1153
1207
|
MAYOR,
|
|
1154
1208
|
MENOR,
|
|
1209
|
+
MIN,
|
|
1155
1210
|
NOTNULL,
|
|
1156
1211
|
NOW,
|
|
1157
1212
|
NULL,
|
|
@@ -1160,6 +1215,8 @@ export {
|
|
|
1160
1215
|
ORQ,
|
|
1161
1216
|
ORQD,
|
|
1162
1217
|
QueryBuilder,
|
|
1218
|
+
ROUND,
|
|
1219
|
+
SUM,
|
|
1163
1220
|
Select,
|
|
1164
1221
|
UP,
|
|
1165
1222
|
Update,
|