zormz 1.4.2 → 1.4.4

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
@@ -243,9 +243,102 @@ const response = await DB.Select([
243
243
  )
244
244
  .execute();
245
245
  ```
246
+ ---
247
+
248
+ ## Operadores y Helpers SQL
249
+
250
+
251
+ ### eq(valor1,valor2,literal = true)
252
+ comparacion de igualdad
253
+
254
+ ```ts
255
+ eq("dni", dni);//2do valor como variable
256
+ eq("id","idLaptops",true)//2do valor como campo de tabla
257
+ ```
258
+
259
+ ### neq(valor1,valor2,literal = true)
260
+ comparacion de negacion
261
+
262
+ ```ts
263
+ neq("dni", dni);//2do valor como variable
264
+ neq("id","idLaptops",true)//2do valor como campo de tabla
265
+ ```
246
266
 
247
267
  ---
248
268
 
269
+ ### AND(...condiciones)
270
+ Agrupa múltiples condiciones con `AND`.
271
+
272
+ ```ts
273
+ AND(eq(), eq(), neq())
274
+ ```
275
+
276
+ ### OR(...condiciones)
277
+ Agrupa múltiples condiciones con `OR`.
278
+
279
+ ```ts
280
+ OR(neq(), eq(), eq())
281
+ ```
282
+
283
+ ### ORQ(campo,...valores)
284
+ Genera multiples comparaciones `OR` para un mismo campo.
285
+
286
+ ```ts
287
+ ORQ("id",1,2,3);
288
+ // => id = 1 or id = 2 or id = 3
289
+ ```
290
+ ---
291
+ ### ILIKE(campo,valor)
292
+ Comparacion insensible a mayusculas/minusculas
293
+
294
+ ```ts
295
+ ILIKE('nombre','%juan%');
296
+ // => nombre ILIKE '%juan%'
297
+ ```
298
+
299
+ ### NOW(campo,dias,minor = true)
300
+ Compara una fecha con la fecha actual menos X días.
301
+ ```ts
302
+ NOW('fecha_creacion', 7)
303
+ // => ( fecha_creacion < NOW() - INTERVAL '7 days')
304
+
305
+ NOW('fecha_creacion', 7, false)
306
+ // => ( fecha_creacion > NOW() - INTERVAL '7 days')
307
+
308
+ ```
309
+ ---
310
+ ### NULL(campo)
311
+ valida si un campo es NULL
312
+ ```ts
313
+ NULL('delete_at');
314
+ //=> delete_at IS NULL
315
+ ```
316
+
317
+ ### NOTNULL(campo)
318
+ valida si un campo no es NULL
319
+ ```ts
320
+ NOTNULL('deleted_at')
321
+ // => deleted_at IS NOT NULL
322
+ ```
323
+ ---
324
+
325
+
326
+ ### MAYOR(campo,valor)
327
+ Comparacion mayor que (`>`)
328
+ ```ts
329
+
330
+ MAYOR('edad',18);
331
+ // => edad > 18
332
+ ```
333
+ ### MENOR(campo,valor)
334
+ Comparacion menor que (`<`)
335
+ ```ts
336
+ MENOR('edad', 18)
337
+ // => edad < 18
338
+
339
+ ```
340
+ ---
341
+
249
342
  ## Ejemplo de Uso
250
343
 
251
344
  ```ts
@@ -306,14 +399,13 @@ pruebaData().catch(console.error);
306
399
  ```
307
400
 
308
401
  ---
309
-
310
402
  ## Notas
311
403
 
312
404
  - ORM en version inicial con enfoque de tipado y autompletado
313
405
  - Compatible con **MYSQL** y **PG**
314
406
  - Preparado para extenderse
315
407
  - Las versiones +1.3.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
316
- - version estable 1.4.0
408
+ - version estable 1.4.2
317
409
 
318
410
  ## Licencia
319
411
 
package/dist/index.d.mts CHANGED
@@ -338,6 +338,19 @@ declare const NOTNULL: (variable: string) => string;
338
338
  * eq('id',valor1, false)
339
339
  */
340
340
  declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
341
+ /**
342
+ *
343
+ * @param {(string | number | boolean )} valor1 - primer valor
344
+ * @param {(string | number | boolean )} valor2 - segundo valor
345
+ * @param {(boolean )} literal
346
+ *
347
+ * @example
348
+ * //en caso sea un valores normalres
349
+ * neq('id','1')
350
+ * //en caso de que seaq un valor de tabla columna
351
+ * neq('id',valor1, false)
352
+ */
353
+ declare const neq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
341
354
  /**
342
355
  *
343
356
  * @param {string} valor
@@ -466,4 +479,4 @@ declare class Money {
466
479
  }
467
480
  declare function money(presicion?: number, decimales?: number): Money;
468
481
 
469
- 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, timestamp, type valor, varchar };
482
+ 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 };
package/dist/index.d.ts CHANGED
@@ -338,6 +338,19 @@ declare const NOTNULL: (variable: string) => string;
338
338
  * eq('id',valor1, false)
339
339
  */
340
340
  declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
341
+ /**
342
+ *
343
+ * @param {(string | number | boolean )} valor1 - primer valor
344
+ * @param {(string | number | boolean )} valor2 - segundo valor
345
+ * @param {(boolean )} literal
346
+ *
347
+ * @example
348
+ * //en caso sea un valores normalres
349
+ * neq('id','1')
350
+ * //en caso de que seaq un valor de tabla columna
351
+ * neq('id',valor1, false)
352
+ */
353
+ declare const neq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
341
354
  /**
342
355
  *
343
356
  * @param {string} valor
@@ -466,4 +479,4 @@ declare class Money {
466
479
  }
467
480
  declare function money(presicion?: number, decimales?: number): Money;
468
481
 
469
- 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, timestamp, type valor, varchar };
482
+ 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 };
package/dist/index.js CHANGED
@@ -64,6 +64,7 @@ __export(index_exports, {
64
64
  getTipoConexion: () => getTipoConexion,
65
65
  int: () => int,
66
66
  money: () => money,
67
+ neq: () => neq,
67
68
  timestamp: () => timestamp,
68
69
  varchar: () => varchar
69
70
  });
@@ -517,10 +518,12 @@ var QueryBuilder = class {
517
518
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
518
519
  });
519
520
  let response = [];
520
- if (this.returning !== void 0) {
521
+ if (this.returning !== void 0 && arrayArrays) {
521
522
  for (let i = 0; i < this.valores.length; i++) {
522
523
  response.push(respuesta.insertId + i);
523
524
  }
525
+ } else {
526
+ response.push(respuesta.insertId);
524
527
  }
525
528
  return response;
526
529
  } else if (this.conexion.tipo === "pg") {
@@ -721,6 +724,14 @@ var eq = (valor1, valor2, literal = true) => {
721
724
  }
722
725
  return `${valor1} = '${valor2}'`;
723
726
  };
727
+ var neq = (valor1, valor2, literal = true) => {
728
+ if (typeof valor1 === "string") valor1 = valor1.trim();
729
+ if (typeof valor2 === "string") valor2 = valor2.trim();
730
+ if (!literal) {
731
+ return `${valor1} != ${valor2}`;
732
+ }
733
+ return `${valor1} != '${valor2}'`;
734
+ };
724
735
  var MAYOR = (valor, valor2) => {
725
736
  return ` ${valor} > ${valor2} `;
726
737
  };
@@ -1203,6 +1214,7 @@ function money(presicion = 10, decimales = 2) {
1203
1214
  getTipoConexion,
1204
1215
  int,
1205
1216
  money,
1217
+ neq,
1206
1218
  timestamp,
1207
1219
  varchar
1208
1220
  });
package/dist/index.mjs CHANGED
@@ -454,10 +454,12 @@ var QueryBuilder = class {
454
454
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
455
455
  });
456
456
  let response = [];
457
- if (this.returning !== void 0) {
457
+ if (this.returning !== void 0 && arrayArrays) {
458
458
  for (let i = 0; i < this.valores.length; i++) {
459
459
  response.push(respuesta.insertId + i);
460
460
  }
461
+ } else {
462
+ response.push(respuesta.insertId);
461
463
  }
462
464
  return response;
463
465
  } else if (this.conexion.tipo === "pg") {
@@ -658,6 +660,14 @@ var eq = (valor1, valor2, literal = true) => {
658
660
  }
659
661
  return `${valor1} = '${valor2}'`;
660
662
  };
663
+ var neq = (valor1, valor2, literal = true) => {
664
+ if (typeof valor1 === "string") valor1 = valor1.trim();
665
+ if (typeof valor2 === "string") valor2 = valor2.trim();
666
+ if (!literal) {
667
+ return `${valor1} != ${valor2}`;
668
+ }
669
+ return `${valor1} != '${valor2}'`;
670
+ };
661
671
  var MAYOR = (valor, valor2) => {
662
672
  return ` ${valor} > ${valor2} `;
663
673
  };
@@ -1139,6 +1149,7 @@ export {
1139
1149
  getTipoConexion,
1140
1150
  int,
1141
1151
  money,
1152
+ neq,
1142
1153
  timestamp,
1143
1154
  varchar
1144
1155
  };
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Un ORM que busca ser ligero y facil de usar",
5
5
  "author": "yukio-kayaba",
6
6
  "license": "ISC",
7
7
  "keywords": [
8
8
  "orm",
9
+ "ORM",
9
10
  "database",
10
11
  "postgresql",
11
12
  "mysql",
12
13
  "sql",
13
14
  "typescript",
14
- "zomrz",
15
+ "zormz",
15
16
  "pg"
16
17
  ],
17
18
  "main": "./dist/index.cjs",