zormz 1.4.7 → 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 CHANGED
@@ -273,6 +273,15 @@ Agrupa múltiples condiciones con `AND`.
273
273
  AND(eq(), eq(), neq())
274
274
  ```
275
275
 
276
+
277
+ ### ANDD(...condiciones)
278
+ Agrupa múltiples condiciones con `AND`.
279
+
280
+ ```ts
281
+ ANDD([eq(), eq(), neq()])
282
+ ```
283
+
284
+
276
285
  ### OR(...condiciones)
277
286
  Agrupa múltiples condiciones con `OR`.
278
287
 
@@ -280,6 +289,14 @@ Agrupa múltiples condiciones con `OR`.
280
289
  OR(neq(), eq(), eq())
281
290
  ```
282
291
 
292
+ ### ORD([])
293
+ Agrupa múltiples condiciones con `OR`.
294
+
295
+ ```ts
296
+ ORD([neq(), eq(), eq()])
297
+ ```
298
+
299
+
283
300
  ### ORQ(campo,...valores)
284
301
  Genera multiples comparaciones `OR` para un mismo campo.
285
302
 
@@ -287,6 +304,14 @@ Genera multiples comparaciones `OR` para un mismo campo.
287
304
  ORQ("id",1,2,3);
288
305
  // => id = 1 or id = 2 or id = 3
289
306
  ```
307
+ ### ORQD(campo,valores[])
308
+ Genera multiples comparaciones `OR` para un mismo campo.
309
+
310
+ ```ts
311
+ ORQD("id",[1,2,3]);
312
+ // => id = 1 or id = 2 or id = 3
313
+ ```
314
+
290
315
  ---
291
316
  ### ILIKE(campo,valor)
292
317
  Comparacion insensible a mayusculas/minusculas
@@ -339,7 +364,212 @@ MENOR('edad', 18)
339
364
  ```
340
365
  ---
341
366
 
342
- ## Ejemplo de Uso
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
343
573
 
344
574
  ```ts
345
575
  import {
@@ -404,9 +634,8 @@ pruebaData().catch(console.error);
404
634
  - ORM en version inicial con enfoque de tipado y autompletado
405
635
  - Compatible con **MYSQL** y **PG**
406
636
  - Preparado para extenderse
407
- - Las versiones +1.3.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
408
- - version estable 1.4.6
409
- - 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
410
639
 
411
640
  ## Licencia
412
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 salo dato
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[] | undefined>;
239
+ execute(see?: boolean): Promise<any[]>;
213
240
  }
214
241
 
215
242
  type Valores = Record<string, string | number | undefined>;
@@ -278,6 +305,7 @@ type Valor = string | number | boolean;
278
305
  * AND(eq(),eq(),eq(),eq(),OR())
279
306
  */
280
307
  declare const AND: (...valor1: Valor[]) => string;
308
+ declare function ANDD(valores: string[]): string;
281
309
  /**
282
310
  *
283
311
  * @param {(string | number | boolean )} valor1 - eq(val,val1)
@@ -288,6 +316,14 @@ declare const AND: (...valor1: Valor[]) => string;
288
316
  * OR(eq(),eq(),eq(),eq(),AND())
289
317
  */
290
318
  declare const OR: (...valor1: Valor[]) => string;
319
+ /**
320
+ *
321
+ * @param {string} valores
322
+ * @returns
323
+ * @example
324
+ * ORD([eq(),eq()])
325
+ */
326
+ declare const ORD: (valores: string[]) => string;
291
327
  /**
292
328
  *
293
329
  * @param {Valor} condicion1
@@ -298,6 +334,17 @@ declare const OR: (...valor1: Valor[]) => string;
298
334
  * @returns
299
335
  */
300
336
  declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
337
+ /**
338
+ *
339
+ * @param {string} condicion
340
+ * @param {Valor[]} valores
341
+ * @returns
342
+ * @example
343
+ *
344
+ * ORQD("correos",["example@gmail.com","example2@gmail.com"])
345
+ *
346
+ */
347
+ declare const ORQD: (condicion: string, valores: Valor[]) => string;
301
348
  /**
302
349
  *
303
350
  * @param {string} valor1
@@ -480,4 +527,81 @@ declare class Money {
480
527
  }
481
528
  declare function money(presicion?: number, decimales?: number): Money;
482
529
 
483
- export { AND, BDconnection, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, 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 };
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 salo dato
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[] | undefined>;
239
+ execute(see?: boolean): Promise<any[]>;
213
240
  }
214
241
 
215
242
  type Valores = Record<string, string | number | undefined>;
@@ -278,6 +305,7 @@ type Valor = string | number | boolean;
278
305
  * AND(eq(),eq(),eq(),eq(),OR())
279
306
  */
280
307
  declare const AND: (...valor1: Valor[]) => string;
308
+ declare function ANDD(valores: string[]): string;
281
309
  /**
282
310
  *
283
311
  * @param {(string | number | boolean )} valor1 - eq(val,val1)
@@ -288,6 +316,14 @@ declare const AND: (...valor1: Valor[]) => string;
288
316
  * OR(eq(),eq(),eq(),eq(),AND())
289
317
  */
290
318
  declare const OR: (...valor1: Valor[]) => string;
319
+ /**
320
+ *
321
+ * @param {string} valores
322
+ * @returns
323
+ * @example
324
+ * ORD([eq(),eq()])
325
+ */
326
+ declare const ORD: (valores: string[]) => string;
291
327
  /**
292
328
  *
293
329
  * @param {Valor} condicion1
@@ -298,6 +334,17 @@ declare const OR: (...valor1: Valor[]) => string;
298
334
  * @returns
299
335
  */
300
336
  declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
337
+ /**
338
+ *
339
+ * @param {string} condicion
340
+ * @param {Valor[]} valores
341
+ * @returns
342
+ * @example
343
+ *
344
+ * ORQD("correos",["example@gmail.com","example2@gmail.com"])
345
+ *
346
+ */
347
+ declare const ORQD: (condicion: string, valores: Valor[]) => string;
301
348
  /**
302
349
  *
303
350
  * @param {string} valor1
@@ -480,4 +527,81 @@ declare class Money {
480
527
  }
481
528
  declare function money(presicion?: number, decimales?: number): Money;
482
529
 
483
- export { AND, BDconnection, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, 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 };
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
@@ -38,19 +38,28 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
38
38
  var index_exports = {};
39
39
  __export(index_exports, {
40
40
  AND: () => AND,
41
+ ANDD: () => ANDD,
42
+ AVG: () => AVG,
41
43
  BDconnection: () => BDconnection,
44
+ COUNT: () => COUNT,
42
45
  CURRENT_TIMESTAMP: () => CURRENT_TIMESTAMP,
43
46
  DB: () => DB,
44
47
  DeleteR: () => DeleteR,
45
48
  ILIKE: () => ILIKE,
49
+ MAX: () => MAX,
46
50
  MAYOR: () => MAYOR,
47
51
  MENOR: () => MENOR,
52
+ MIN: () => MIN,
48
53
  NOTNULL: () => NOTNULL,
49
54
  NOW: () => NOW,
50
55
  NULL: () => NULL,
51
56
  OR: () => OR,
57
+ ORD: () => ORD,
52
58
  ORQ: () => ORQ,
59
+ ORQD: () => ORQD,
53
60
  QueryBuilder: () => QueryBuilder,
61
+ ROUND: () => ROUND,
62
+ SUM: () => SUM,
54
63
  Select: () => Select,
55
64
  UP: () => UP,
56
65
  Update: () => Update,
@@ -171,18 +180,23 @@ var BDconnection = class {
171
180
  }
172
181
  const respuesta = await pool2.query(query2, valores);
173
182
  if (!respuesta) {
174
- throw new Error(` Este usuario no esta registrado `);
183
+ throw new Error(` Fallo la consulta `);
175
184
  }
176
185
  return respuesta;
186
+ } else {
187
+ return [];
177
188
  }
178
189
  } catch (error) {
179
- if (!alertar) return;
190
+ if (!alertar) return [];
180
191
  if (typeof error === "object" && error !== null && "code" in error) {
181
192
  if (error.code === "ETIMEDOUT") {
182
193
  throw new Error(`Su red esta limitando el acceso`);
183
194
  }
184
- throw new Error(`${mensaje} : ${error} query ${query}`);
195
+ console.log(`${mensaje} : ${error} query ${query}`);
196
+ throw new Error(`data query invalid`);
185
197
  }
198
+ console.error(error);
199
+ throw error;
186
200
  }
187
201
  }
188
202
  };
@@ -354,6 +368,10 @@ async function dropTable(nombreTabla) {
354
368
  mensaje: "Error al eliminar la tabla",
355
369
  alertar: false
356
370
  });
371
+ if (response.command === "DROP") {
372
+ console.log(`\u{1F44D}\u{1F44D} Se elimino con exito la tabla ${nombreTabla} \u{1F44D}`);
373
+ return;
374
+ }
357
375
  console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
358
376
  }
359
377
  }
@@ -437,7 +455,7 @@ var QueryBuilder = class {
437
455
  *
438
456
  * @param {arrayData | arrayDatas} values
439
457
  * @example
440
- * //para un salo dato
458
+ * //para un solo dato
441
459
  * ['dato1','dato2']
442
460
  * //para varios datos
443
461
  * [['dato1','dato1/2'],['dato2','dato2/2']]
@@ -673,7 +691,10 @@ var Select = class {
673
691
  query,
674
692
  mensaje: "Ocurrio un error realizar un select"
675
693
  });
694
+ if (respuesta.rows === void 0) return [];
676
695
  return respuesta.rows;
696
+ } else {
697
+ return [];
677
698
  }
678
699
  }
679
700
  };
@@ -681,11 +702,19 @@ var Select = class {
681
702
  // conection/middleware/condicionals.ts
682
703
  var AND = (...valor1) => {
683
704
  const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
684
- return `(${separacion})`;
705
+ return ` (${separacion}) `;
685
706
  };
707
+ function ANDD(valores) {
708
+ const separacion = valores.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
709
+ return ` (${separacion}) `;
710
+ }
686
711
  var OR = (...valor1) => {
687
712
  const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
688
- return `(${separadosComas})`;
713
+ return ` (${separadosComas}) `;
714
+ };
715
+ var ORD = (valores) => {
716
+ const separador = valores.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
717
+ return ` (${separador}) `;
689
718
  };
690
719
  var ORQ = (condicion1, ...condicionals) => {
691
720
  const data2 = condicionals.map((dato) => {
@@ -693,7 +722,15 @@ var ORQ = (condicion1, ...condicionals) => {
693
722
  return ` ${condicion1} = '${dato}' `;
694
723
  });
695
724
  const separador = data2.join(" or ");
696
- return separador;
725
+ return ` (${separador}) `;
726
+ };
727
+ var ORQD = (condicion, valores) => {
728
+ const data = valores.map((dato) => {
729
+ if (typeof dato == "number" || typeof dato === "boolean") return ` ${condicion} = ${dato}`;
730
+ return ` ${condicion} = '${dato}' `;
731
+ });
732
+ const separador = data.join(" or ");
733
+ return ` ( ${separador} ) `;
697
734
  };
698
735
  var ILIKE = (valor1, valor2) => {
699
736
  return `${valor1} ILIKE '${valor2}'`;
@@ -1185,22 +1222,75 @@ var Money = class {
1185
1222
  function money(presicion = 10, decimales = 2) {
1186
1223
  return new Money(presicion, decimales);
1187
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
+ };
1188
1269
  // Annotate the CommonJS export names for ESM import in node:
1189
1270
  0 && (module.exports = {
1190
1271
  AND,
1272
+ ANDD,
1273
+ AVG,
1191
1274
  BDconnection,
1275
+ COUNT,
1192
1276
  CURRENT_TIMESTAMP,
1193
1277
  DB,
1194
1278
  DeleteR,
1195
1279
  ILIKE,
1280
+ MAX,
1196
1281
  MAYOR,
1197
1282
  MENOR,
1283
+ MIN,
1198
1284
  NOTNULL,
1199
1285
  NOW,
1200
1286
  NULL,
1201
1287
  OR,
1288
+ ORD,
1202
1289
  ORQ,
1290
+ ORQD,
1203
1291
  QueryBuilder,
1292
+ ROUND,
1293
+ SUM,
1204
1294
  Select,
1205
1295
  UP,
1206
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(` Este usuario no esta registrado `);
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
- throw new Error(`${mensaje} : ${error} query ${query}`);
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,6 +295,10 @@ async function dropTable(nombreTabla) {
290
295
  mensaje: "Error al eliminar la tabla",
291
296
  alertar: false
292
297
  });
298
+ if (response.command === "DROP") {
299
+ console.log(`\u{1F44D}\u{1F44D} Se elimino con exito la tabla ${nombreTabla} \u{1F44D}`);
300
+ return;
301
+ }
293
302
  console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
294
303
  }
295
304
  }
@@ -373,7 +382,7 @@ var QueryBuilder = class {
373
382
  *
374
383
  * @param {arrayData | arrayDatas} values
375
384
  * @example
376
- * //para un salo dato
385
+ * //para un solo dato
377
386
  * ['dato1','dato2']
378
387
  * //para varios datos
379
388
  * [['dato1','dato1/2'],['dato2','dato2/2']]
@@ -609,7 +618,10 @@ var Select = class {
609
618
  query,
610
619
  mensaje: "Ocurrio un error realizar un select"
611
620
  });
621
+ if (respuesta.rows === void 0) return [];
612
622
  return respuesta.rows;
623
+ } else {
624
+ return [];
613
625
  }
614
626
  }
615
627
  };
@@ -617,11 +629,19 @@ var Select = class {
617
629
  // conection/middleware/condicionals.ts
618
630
  var AND = (...valor1) => {
619
631
  const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
620
- return `(${separacion})`;
632
+ return ` (${separacion}) `;
621
633
  };
634
+ function ANDD(valores) {
635
+ const separacion = valores.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
636
+ return ` (${separacion}) `;
637
+ }
622
638
  var OR = (...valor1) => {
623
639
  const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
624
- return `(${separadosComas})`;
640
+ return ` (${separadosComas}) `;
641
+ };
642
+ var ORD = (valores) => {
643
+ const separador = valores.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
644
+ return ` (${separador}) `;
625
645
  };
626
646
  var ORQ = (condicion1, ...condicionals) => {
627
647
  const data2 = condicionals.map((dato) => {
@@ -629,7 +649,15 @@ var ORQ = (condicion1, ...condicionals) => {
629
649
  return ` ${condicion1} = '${dato}' `;
630
650
  });
631
651
  const separador = data2.join(" or ");
632
- return separador;
652
+ return ` (${separador}) `;
653
+ };
654
+ var ORQD = (condicion, valores) => {
655
+ const data = valores.map((dato) => {
656
+ if (typeof dato == "number" || typeof dato === "boolean") return ` ${condicion} = ${dato}`;
657
+ return ` ${condicion} = '${dato}' `;
658
+ });
659
+ const separador = data.join(" or ");
660
+ return ` ( ${separador} ) `;
633
661
  };
634
662
  var ILIKE = (valor1, valor2) => {
635
663
  return `${valor1} ILIKE '${valor2}'`;
@@ -1121,21 +1149,74 @@ var Money = class {
1121
1149
  function money(presicion = 10, decimales = 2) {
1122
1150
  return new Money(presicion, decimales);
1123
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
+ };
1124
1196
  export {
1125
1197
  AND,
1198
+ ANDD,
1199
+ AVG,
1126
1200
  BDconnection,
1201
+ COUNT,
1127
1202
  CURRENT_TIMESTAMP,
1128
1203
  DB,
1129
1204
  DeleteR,
1130
1205
  ILIKE,
1206
+ MAX,
1131
1207
  MAYOR,
1132
1208
  MENOR,
1209
+ MIN,
1133
1210
  NOTNULL,
1134
1211
  NOW,
1135
1212
  NULL,
1136
1213
  OR,
1214
+ ORD,
1137
1215
  ORQ,
1216
+ ORQD,
1138
1217
  QueryBuilder,
1218
+ ROUND,
1219
+ SUM,
1139
1220
  Select,
1140
1221
  UP,
1141
1222
  Update,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.4.7",
3
+ "version": "1.6.0",
4
4
  "description": "Un ORM que busca ser ligero y facil de usar",
5
5
  "author": "yukio-kayaba",
6
6
  "license": "ISC",