zormz 1.4.2 → 1.4.3
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 +94 -2
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +10 -0
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
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.
|
|
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
|
});
|
|
@@ -721,6 +722,14 @@ var eq = (valor1, valor2, literal = true) => {
|
|
|
721
722
|
}
|
|
722
723
|
return `${valor1} = '${valor2}'`;
|
|
723
724
|
};
|
|
725
|
+
var neq = (valor1, valor2, literal = true) => {
|
|
726
|
+
if (typeof valor1 === "string") valor1 = valor1.trim();
|
|
727
|
+
if (typeof valor2 === "string") valor2 = valor2.trim();
|
|
728
|
+
if (!literal) {
|
|
729
|
+
return `${valor1} != ${valor2}`;
|
|
730
|
+
}
|
|
731
|
+
return `${valor1} != '${valor2}'`;
|
|
732
|
+
};
|
|
724
733
|
var MAYOR = (valor, valor2) => {
|
|
725
734
|
return ` ${valor} > ${valor2} `;
|
|
726
735
|
};
|
|
@@ -1203,6 +1212,7 @@ function money(presicion = 10, decimales = 2) {
|
|
|
1203
1212
|
getTipoConexion,
|
|
1204
1213
|
int,
|
|
1205
1214
|
money,
|
|
1215
|
+
neq,
|
|
1206
1216
|
timestamp,
|
|
1207
1217
|
varchar
|
|
1208
1218
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -658,6 +658,14 @@ var eq = (valor1, valor2, literal = true) => {
|
|
|
658
658
|
}
|
|
659
659
|
return `${valor1} = '${valor2}'`;
|
|
660
660
|
};
|
|
661
|
+
var neq = (valor1, valor2, literal = true) => {
|
|
662
|
+
if (typeof valor1 === "string") valor1 = valor1.trim();
|
|
663
|
+
if (typeof valor2 === "string") valor2 = valor2.trim();
|
|
664
|
+
if (!literal) {
|
|
665
|
+
return `${valor1} != ${valor2}`;
|
|
666
|
+
}
|
|
667
|
+
return `${valor1} != '${valor2}'`;
|
|
668
|
+
};
|
|
661
669
|
var MAYOR = (valor, valor2) => {
|
|
662
670
|
return ` ${valor} > ${valor2} `;
|
|
663
671
|
};
|
|
@@ -1139,6 +1147,7 @@ export {
|
|
|
1139
1147
|
getTipoConexion,
|
|
1140
1148
|
int,
|
|
1141
1149
|
money,
|
|
1150
|
+
neq,
|
|
1142
1151
|
timestamp,
|
|
1143
1152
|
varchar
|
|
1144
1153
|
};
|