zormz 1.0.1 → 1.1.1
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 +23 -0
- package/dist/index.cjs +33 -14
- package/dist/index.d.cts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.js +28 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# ZORMZ
|
|
2
2
|
|
|
3
3
|
Un ORM ligero escrito en TypeScript para MySQL y PostgreSQL, diseñado para ser simple, rápido y extensible.
|
|
4
|
+
por ahora solo es posible conectarse a una base de datos.
|
|
4
5
|
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -92,6 +93,24 @@ getConexion("pg",conexionPg);
|
|
|
92
93
|
```
|
|
93
94
|
---
|
|
94
95
|
|
|
96
|
+
## Definir tablas para uso dev
|
|
97
|
+
* Puede exportarse como una constante para programarlo y guiarnos facilmente
|
|
98
|
+
### defineTable
|
|
99
|
+
* `export const productosPrueba = defineTable("productosPrueba",{`
|
|
100
|
+
* `id:"id",`
|
|
101
|
+
* `nombre:"nombre",`
|
|
102
|
+
* `descripcion:"descripcion"`
|
|
103
|
+
* `});`
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Ejemplo: definicion de tabla
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const response = await DB.Insert(productosPrueba(),
|
|
110
|
+
[productosPrueba.nombre,productosPrueba.descripcion]).Values(['yunno','magic wind']).execute();
|
|
111
|
+
```
|
|
112
|
+
---
|
|
113
|
+
|
|
95
114
|
## Métodos disponibles
|
|
96
115
|
|
|
97
116
|
### **Select**
|
|
@@ -169,6 +188,10 @@ pruebaData().catch((e) => {
|
|
|
169
188
|
|
|
170
189
|
---
|
|
171
190
|
|
|
191
|
+
|
|
192
|
+
|
|
172
193
|
## 📄 Licencia
|
|
173
194
|
|
|
174
195
|
ISC © Yukio-kayaba
|
|
196
|
+
|
|
197
|
+
[](https://github.com/yukio-kayaba/)
|
package/dist/index.cjs
CHANGED
|
@@ -42,19 +42,20 @@ __export(index_exports, {
|
|
|
42
42
|
DB: () => DB,
|
|
43
43
|
DeleteR: () => DeleteR,
|
|
44
44
|
ILIKE: () => ILIKE,
|
|
45
|
+
MAYOR: () => MAYOR,
|
|
46
|
+
MENOR: () => MENOR,
|
|
45
47
|
NOTNULL: () => NOTNULL,
|
|
48
|
+
NOW: () => NOW,
|
|
46
49
|
NULL: () => NULL,
|
|
47
50
|
OR: () => OR,
|
|
48
51
|
ORQ: () => ORQ,
|
|
49
52
|
QueryBuilder: () => QueryBuilder,
|
|
50
53
|
Select: () => Select,
|
|
51
54
|
Update: () => Update,
|
|
55
|
+
defineTable: () => defineTable,
|
|
52
56
|
eq: () => eq,
|
|
53
57
|
getConexion: () => getConexion,
|
|
54
|
-
getRed: () => getRed
|
|
55
|
-
mayor: () => mayor,
|
|
56
|
-
menor: () => menor,
|
|
57
|
-
now: () => now
|
|
58
|
+
getRed: () => getRed
|
|
58
59
|
});
|
|
59
60
|
module.exports = __toCommonJS(index_exports);
|
|
60
61
|
|
|
@@ -161,6 +162,23 @@ function getConexion(bd, datos) {
|
|
|
161
162
|
function getRed() {
|
|
162
163
|
return conexion1;
|
|
163
164
|
}
|
|
165
|
+
function defineTable(tableName, columns) {
|
|
166
|
+
return new Proxy(columns, {
|
|
167
|
+
get(target, prop) {
|
|
168
|
+
if (prop === "name") return tableName;
|
|
169
|
+
if (prop === "toString") return () => tableName;
|
|
170
|
+
if (prop === "valueOf") return () => tableName;
|
|
171
|
+
const column = target[prop];
|
|
172
|
+
if (column !== void 0) {
|
|
173
|
+
return `${tableName}.${column}`;
|
|
174
|
+
}
|
|
175
|
+
return "";
|
|
176
|
+
},
|
|
177
|
+
apply() {
|
|
178
|
+
return tableName;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
164
182
|
|
|
165
183
|
// conection/middleware/delete.ts
|
|
166
184
|
var _condicion, _tabla;
|
|
@@ -403,11 +421,11 @@ var Select = class {
|
|
|
403
421
|
|
|
404
422
|
// conection/middleware/condicionals.ts
|
|
405
423
|
var AND = (...valor1) => {
|
|
406
|
-
const separacion = valor1.join(" and ");
|
|
424
|
+
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
407
425
|
return `(${separacion})`;
|
|
408
426
|
};
|
|
409
427
|
var OR = (...valor1) => {
|
|
410
|
-
const separadosComas = valor1.join(" or ");
|
|
428
|
+
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
411
429
|
return `(${separadosComas})`;
|
|
412
430
|
};
|
|
413
431
|
var ORQ = (condicion1, ...condicionals) => {
|
|
@@ -419,9 +437,9 @@ var ORQ = (condicion1, ...condicionals) => {
|
|
|
419
437
|
return separador;
|
|
420
438
|
};
|
|
421
439
|
var ILIKE = (valor1, valor2) => {
|
|
422
|
-
return `${valor1} ILIKE '
|
|
440
|
+
return `${valor1} ILIKE '${valor2}'`;
|
|
423
441
|
};
|
|
424
|
-
var
|
|
442
|
+
var NOW = (variable, diasTrancurridos, minor = true) => {
|
|
425
443
|
if (typeof variable !== "string") {
|
|
426
444
|
throw new Error("Variable no valida");
|
|
427
445
|
}
|
|
@@ -447,10 +465,10 @@ var eq = (valor1, valor2, literal = true) => {
|
|
|
447
465
|
}
|
|
448
466
|
return `${valor1} = '${valor2}'`;
|
|
449
467
|
};
|
|
450
|
-
var
|
|
468
|
+
var MAYOR = (valor, valor2) => {
|
|
451
469
|
return ` ${valor} > ${valor2} `;
|
|
452
470
|
};
|
|
453
|
-
var
|
|
471
|
+
var MENOR = (valor, valor2) => {
|
|
454
472
|
return ` ${valor} < ${valor2} `;
|
|
455
473
|
};
|
|
456
474
|
|
|
@@ -575,17 +593,18 @@ var DB = class {
|
|
|
575
593
|
DB,
|
|
576
594
|
DeleteR,
|
|
577
595
|
ILIKE,
|
|
596
|
+
MAYOR,
|
|
597
|
+
MENOR,
|
|
578
598
|
NOTNULL,
|
|
599
|
+
NOW,
|
|
579
600
|
NULL,
|
|
580
601
|
OR,
|
|
581
602
|
ORQ,
|
|
582
603
|
QueryBuilder,
|
|
583
604
|
Select,
|
|
584
605
|
Update,
|
|
606
|
+
defineTable,
|
|
585
607
|
eq,
|
|
586
608
|
getConexion,
|
|
587
|
-
getRed
|
|
588
|
-
mayor,
|
|
589
|
-
menor,
|
|
590
|
-
now
|
|
609
|
+
getRed
|
|
591
610
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -31,6 +31,19 @@ declare class BDconnection {
|
|
|
31
31
|
*/
|
|
32
32
|
declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
|
|
33
33
|
declare function getRed(): BDconnection;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {string} tableName
|
|
37
|
+
* @param {string} columns
|
|
38
|
+
* @example
|
|
39
|
+
* export const productosPrueba = defineTable("productosPrueba",{
|
|
40
|
+
* id:"id",
|
|
41
|
+
* nombre:"nombre",
|
|
42
|
+
* descripcion:"descripcion"
|
|
43
|
+
* });
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
declare function defineTable<T extends Record<string, string>>(tableName: string, columns: T): T;
|
|
34
47
|
|
|
35
48
|
declare class DeleteR {
|
|
36
49
|
#private;
|
|
@@ -229,13 +242,23 @@ declare const OR: (...valor1: Valor[]) => string;
|
|
|
229
242
|
* @returns
|
|
230
243
|
*/
|
|
231
244
|
declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param {string} valor1
|
|
248
|
+
* @param {string} valor2
|
|
249
|
+
* @example
|
|
250
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}`))
|
|
251
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `${contenido}%`))
|
|
252
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}%`))
|
|
253
|
+
* @returns
|
|
254
|
+
*/
|
|
232
255
|
declare const ILIKE: (valor1: string, valor2: string) => string;
|
|
233
256
|
/**
|
|
234
257
|
*
|
|
235
258
|
* @param {String} variable -Type timestamp
|
|
236
259
|
* @param {Number} diasTrancurridos -type number
|
|
237
260
|
*/
|
|
238
|
-
declare const
|
|
261
|
+
declare const NOW: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
|
|
239
262
|
/**
|
|
240
263
|
*
|
|
241
264
|
* @param {String} variable - variable
|
|
@@ -260,7 +283,23 @@ declare const NOTNULL: (variable: string) => string;
|
|
|
260
283
|
* eq('id',valor1, false)
|
|
261
284
|
*/
|
|
262
285
|
declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
|
|
263
|
-
|
|
264
|
-
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {string} valor
|
|
289
|
+
* @param {string} valor2
|
|
290
|
+
* @example
|
|
291
|
+
* MAYOR(t_productos.id, `${maxPageSize * 2}`),
|
|
292
|
+
* @returns
|
|
293
|
+
*/
|
|
294
|
+
declare const MAYOR: (valor: string, valor2: string) => string;
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param {string} valor
|
|
298
|
+
* @param {string} valor2
|
|
299
|
+
* @example
|
|
300
|
+
* MENOR(t_productos.id, `${maxPageSize * 2}`),
|
|
301
|
+
* @returns
|
|
302
|
+
*/
|
|
303
|
+
declare const MENOR: (valor: string, valor2: string) => string;
|
|
265
304
|
|
|
266
|
-
export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, NOTNULL, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, eq, getConexion, getRed,
|
|
305
|
+
export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, getConexion, getRed, type valor };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,19 @@ declare class BDconnection {
|
|
|
31
31
|
*/
|
|
32
32
|
declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
|
|
33
33
|
declare function getRed(): BDconnection;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {string} tableName
|
|
37
|
+
* @param {string} columns
|
|
38
|
+
* @example
|
|
39
|
+
* export const productosPrueba = defineTable("productosPrueba",{
|
|
40
|
+
* id:"id",
|
|
41
|
+
* nombre:"nombre",
|
|
42
|
+
* descripcion:"descripcion"
|
|
43
|
+
* });
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
declare function defineTable<T extends Record<string, string>>(tableName: string, columns: T): T;
|
|
34
47
|
|
|
35
48
|
declare class DeleteR {
|
|
36
49
|
#private;
|
|
@@ -229,13 +242,23 @@ declare const OR: (...valor1: Valor[]) => string;
|
|
|
229
242
|
* @returns
|
|
230
243
|
*/
|
|
231
244
|
declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param {string} valor1
|
|
248
|
+
* @param {string} valor2
|
|
249
|
+
* @example
|
|
250
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}`))
|
|
251
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `${contenido}%`))
|
|
252
|
+
* SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}%`))
|
|
253
|
+
* @returns
|
|
254
|
+
*/
|
|
232
255
|
declare const ILIKE: (valor1: string, valor2: string) => string;
|
|
233
256
|
/**
|
|
234
257
|
*
|
|
235
258
|
* @param {String} variable -Type timestamp
|
|
236
259
|
* @param {Number} diasTrancurridos -type number
|
|
237
260
|
*/
|
|
238
|
-
declare const
|
|
261
|
+
declare const NOW: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
|
|
239
262
|
/**
|
|
240
263
|
*
|
|
241
264
|
* @param {String} variable - variable
|
|
@@ -260,7 +283,23 @@ declare const NOTNULL: (variable: string) => string;
|
|
|
260
283
|
* eq('id',valor1, false)
|
|
261
284
|
*/
|
|
262
285
|
declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
|
|
263
|
-
|
|
264
|
-
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {string} valor
|
|
289
|
+
* @param {string} valor2
|
|
290
|
+
* @example
|
|
291
|
+
* MAYOR(t_productos.id, `${maxPageSize * 2}`),
|
|
292
|
+
* @returns
|
|
293
|
+
*/
|
|
294
|
+
declare const MAYOR: (valor: string, valor2: string) => string;
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param {string} valor
|
|
298
|
+
* @param {string} valor2
|
|
299
|
+
* @example
|
|
300
|
+
* MENOR(t_productos.id, `${maxPageSize * 2}`),
|
|
301
|
+
* @returns
|
|
302
|
+
*/
|
|
303
|
+
declare const MENOR: (valor: string, valor2: string) => string;
|
|
265
304
|
|
|
266
|
-
export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, NOTNULL, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, eq, getConexion, getRed,
|
|
305
|
+
export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, getConexion, getRed, type valor };
|
package/dist/index.js
CHANGED
|
@@ -109,6 +109,23 @@ function getConexion(bd, datos) {
|
|
|
109
109
|
function getRed() {
|
|
110
110
|
return conexion1;
|
|
111
111
|
}
|
|
112
|
+
function defineTable(tableName, columns) {
|
|
113
|
+
return new Proxy(columns, {
|
|
114
|
+
get(target, prop) {
|
|
115
|
+
if (prop === "name") return tableName;
|
|
116
|
+
if (prop === "toString") return () => tableName;
|
|
117
|
+
if (prop === "valueOf") return () => tableName;
|
|
118
|
+
const column = target[prop];
|
|
119
|
+
if (column !== void 0) {
|
|
120
|
+
return `${tableName}.${column}`;
|
|
121
|
+
}
|
|
122
|
+
return "";
|
|
123
|
+
},
|
|
124
|
+
apply() {
|
|
125
|
+
return tableName;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
112
129
|
|
|
113
130
|
// conection/middleware/delete.ts
|
|
114
131
|
var _condicion, _tabla;
|
|
@@ -351,11 +368,11 @@ var Select = class {
|
|
|
351
368
|
|
|
352
369
|
// conection/middleware/condicionals.ts
|
|
353
370
|
var AND = (...valor1) => {
|
|
354
|
-
const separacion = valor1.join(" and ");
|
|
371
|
+
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
355
372
|
return `(${separacion})`;
|
|
356
373
|
};
|
|
357
374
|
var OR = (...valor1) => {
|
|
358
|
-
const separadosComas = valor1.join(" or ");
|
|
375
|
+
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
359
376
|
return `(${separadosComas})`;
|
|
360
377
|
};
|
|
361
378
|
var ORQ = (condicion1, ...condicionals) => {
|
|
@@ -367,9 +384,9 @@ var ORQ = (condicion1, ...condicionals) => {
|
|
|
367
384
|
return separador;
|
|
368
385
|
};
|
|
369
386
|
var ILIKE = (valor1, valor2) => {
|
|
370
|
-
return `${valor1} ILIKE '
|
|
387
|
+
return `${valor1} ILIKE '${valor2}'`;
|
|
371
388
|
};
|
|
372
|
-
var
|
|
389
|
+
var NOW = (variable, diasTrancurridos, minor = true) => {
|
|
373
390
|
if (typeof variable !== "string") {
|
|
374
391
|
throw new Error("Variable no valida");
|
|
375
392
|
}
|
|
@@ -395,10 +412,10 @@ var eq = (valor1, valor2, literal = true) => {
|
|
|
395
412
|
}
|
|
396
413
|
return `${valor1} = '${valor2}'`;
|
|
397
414
|
};
|
|
398
|
-
var
|
|
415
|
+
var MAYOR = (valor, valor2) => {
|
|
399
416
|
return ` ${valor} > ${valor2} `;
|
|
400
417
|
};
|
|
401
|
-
var
|
|
418
|
+
var MENOR = (valor, valor2) => {
|
|
402
419
|
return ` ${valor} < ${valor2} `;
|
|
403
420
|
};
|
|
404
421
|
|
|
@@ -522,17 +539,18 @@ export {
|
|
|
522
539
|
DB,
|
|
523
540
|
DeleteR,
|
|
524
541
|
ILIKE,
|
|
542
|
+
MAYOR,
|
|
543
|
+
MENOR,
|
|
525
544
|
NOTNULL,
|
|
545
|
+
NOW,
|
|
526
546
|
NULL,
|
|
527
547
|
OR,
|
|
528
548
|
ORQ,
|
|
529
549
|
QueryBuilder,
|
|
530
550
|
Select,
|
|
531
551
|
Update,
|
|
552
|
+
defineTable,
|
|
532
553
|
eq,
|
|
533
554
|
getConexion,
|
|
534
|
-
getRed
|
|
535
|
-
mayor,
|
|
536
|
-
menor,
|
|
537
|
-
now
|
|
555
|
+
getRed
|
|
538
556
|
};
|