zormz 1.2.3 → 1.2.5
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 +107 -133
- package/dist/{index.d.cts → index.d.mts} +109 -28
- package/dist/index.d.ts +109 -28
- package/dist/index.js +362 -45
- package/dist/{index.cjs → index.mjs} +300 -101
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ZORMZ
|
|
2
2
|
|
|
3
|
-
Un ORM ligero escrito en TypeScript para MySQL y PostgreSQL
|
|
4
|
-
|
|
3
|
+
Un ORM ligero escrito en TypeScript para **MySQL** y **PostgreSQL**, diseñado para ser simple, rápido y extensible.
|
|
4
|
+
Permite conectarse a una base de datos, definir tablas desde TypeScript con autocompletado y tipado, y generar tablas automáticamente.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -11,7 +11,11 @@ por ahora solo es posible conectarse a una base de datos.
|
|
|
11
11
|
* Tipado completo en **TypeScript**
|
|
12
12
|
* Builder con sintaxis encadenada: `select().from().where().execute()`
|
|
13
13
|
* Insert múltiple con arrays
|
|
14
|
-
*
|
|
14
|
+
* Update y Delete con condiciones
|
|
15
|
+
* Definición de columnas con encadenamiento:
|
|
16
|
+
* `int().Pk().$()`
|
|
17
|
+
* `varchar(200).Default("hola").$()`
|
|
18
|
+
* Generación automática de tablas en MySQL y PostgreSQL
|
|
15
19
|
* Sin dependencias pesadas
|
|
16
20
|
* Fácil de extender
|
|
17
21
|
|
|
@@ -21,207 +25,177 @@ por ahora solo es posible conectarse a una base de datos.
|
|
|
21
25
|
|
|
22
26
|
```bash
|
|
23
27
|
npm install zormz
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Uso básico
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
```
|
|
31
30
|
|
|
31
|
+
## Uso basico
|
|
32
|
+
### importacion ESM
|
|
32
33
|
```ts
|
|
33
|
-
import { connecionLocal, getConexion } from "zormz";
|
|
34
|
-
```
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
import { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } from "zormz";
|
|
37
36
|
|
|
38
|
-
```js
|
|
39
|
-
const { connecionLocal, getConexion } = require("zormz");
|
|
40
37
|
```
|
|
38
|
+
### importacion COMMONJS
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
```ts
|
|
41
|
+
const { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } = require("zormz");
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
```
|
|
44
|
+
## Conexion a la base de datos
|
|
45
|
+
### MYSQL
|
|
47
46
|
```ts
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
database: "pruebamaster",
|
|
52
|
-
user: "root",
|
|
47
|
+
const conexionMysql: connecionLocal = {
|
|
48
|
+
database: "pruebas",
|
|
49
|
+
host: "localhost",
|
|
53
50
|
password: "",
|
|
54
51
|
port: 3306,
|
|
55
|
-
|
|
52
|
+
user: "root",
|
|
56
53
|
};
|
|
57
54
|
|
|
58
|
-
getConexion("mysql",
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
55
|
+
getConexion("mysql", conexionMysql);
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
```
|
|
64
58
|
|
|
59
|
+
### PG
|
|
65
60
|
```ts
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
//Conexion por red , aqui solo se pone la ruta que por defecto te arroja la base de datos de la nube
|
|
62
|
+
const conexion2:connecionRed = {
|
|
63
|
+
connectionString:"direccion"
|
|
68
64
|
}
|
|
69
|
-
getConexion("pg",conexionPg);
|
|
70
|
-
```
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
## Métodos disponibles
|
|
75
|
-
|
|
76
|
-
### **Select**
|
|
77
|
-
### **Insert**
|
|
78
|
-
### **Update**
|
|
79
|
-
### **Delete**
|
|
80
65
|
|
|
66
|
+
const conexion: connecionLocal = {
|
|
67
|
+
database: "pruebamaster",
|
|
68
|
+
host: "localhost",
|
|
69
|
+
password: "zainmaster123",
|
|
70
|
+
port: 5432,
|
|
71
|
+
user: "postgres",
|
|
72
|
+
};
|
|
81
73
|
|
|
82
|
-
|
|
74
|
+
getConexion("pg", conexion);
|
|
83
75
|
|
|
84
|
-
|
|
76
|
+
```
|
|
85
77
|
|
|
86
|
-
|
|
78
|
+
## Definicion de Tablas
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
```ts
|
|
81
|
+
export const prueba1 = defineTable("prueba1", {
|
|
82
|
+
id: int().Pk().$(),
|
|
83
|
+
valor: varchar(200).Default("hola").$(),
|
|
84
|
+
resultado: int().Default(0).$(),
|
|
85
|
+
fechaRegistro: timestamp().required().now().$(),
|
|
86
|
+
fechaUpdate: timestamp().required().now().onUpdate().$()
|
|
90
87
|
|
|
91
|
-
|
|
88
|
+
});
|
|
92
89
|
|
|
90
|
+
```
|
|
93
91
|
|
|
94
|
-
###
|
|
92
|
+
### Notas importantes
|
|
93
|
+
* **.pk()** define la columna como clave primaria
|
|
94
|
+
* **.Default()** entrega un valor por defecto
|
|
95
|
+
* **.$()** finaliza la definicion y entrega un valor compatible con *$columns*
|
|
95
96
|
|
|
97
|
+
## Generacion de tablas
|
|
96
98
|
```ts
|
|
97
|
-
|
|
98
|
-
id: { typo: "int", id: true },
|
|
99
|
-
|
|
100
|
-
nombre: {
|
|
101
|
-
typo: "varchar",
|
|
102
|
-
maxLength: 200,
|
|
103
|
-
default: "hola"
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
data: {
|
|
107
|
-
typo: "varchar",
|
|
108
|
-
default: "none magic"
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
edad: {
|
|
112
|
-
typo: "int",
|
|
113
|
-
default:19
|
|
114
|
-
}
|
|
115
|
-
});
|
|
99
|
+
generateTable(prueba1(), prueba1.$columns);
|
|
116
100
|
```
|
|
117
|
-
|
|
118
|
-
### Notas
|
|
119
|
-
|
|
120
|
-
* `defineTable` registra el nombre de la tabla y sus columnas
|
|
121
|
-
* Cada propiedad representa una columna
|
|
122
|
-
* El objetivo actual es **autocompletado y estructura**, no migraciones complejas
|
|
123
|
-
* El sistema está en evolución 😢
|
|
101
|
+
Esto crea la tabla en la base de datos respetando tipos, claves primarias y valores por defecto.
|
|
124
102
|
|
|
125
103
|
---
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
* $columns : es un parametro que por defecto se obtiene al definir la tabla, este reserva gran parte de los datos.
|
|
104
|
+
|
|
105
|
+
## Insertar Datos
|
|
129
106
|
|
|
130
107
|
```ts
|
|
131
|
-
|
|
132
|
-
|
|
108
|
+
await DB.Insert(prueba1(), [prueba1.valor, prueba1.resultado])
|
|
109
|
+
.Values([["hola mundo", 1], ["prueba", 0]])
|
|
110
|
+
.execute();
|
|
133
111
|
|
|
134
112
|
```
|
|
113
|
+
---
|
|
135
114
|
|
|
136
|
-
##
|
|
115
|
+
## Select de Datos
|
|
137
116
|
|
|
138
117
|
```ts
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
118
|
+
const datos = await DB.select()
|
|
119
|
+
.from(prueba1())
|
|
120
|
+
.where(eq(prueba1.id, 1))
|
|
121
|
+
.execute();
|
|
142
122
|
|
|
143
|
-
Resultado esperado:
|
|
144
|
-
|
|
145
|
-
```sql
|
|
146
|
-
INSERT INTO datosPrueba (nombre, data) VALUES (?, ?);
|
|
147
123
|
```
|
|
148
|
-
|
|
149
124
|
---
|
|
150
125
|
|
|
151
|
-
##
|
|
152
|
-
|
|
126
|
+
## Update de Datos
|
|
153
127
|
```ts
|
|
154
|
-
|
|
155
|
-
|
|
128
|
+
await DB.Update(prueba1())
|
|
129
|
+
.set({ valor: "nuevo valor", resultado: 2 })
|
|
130
|
+
.where(eq(prueba1.id, 1))
|
|
131
|
+
.execute();
|
|
132
|
+
|
|
156
133
|
```
|
|
157
134
|
---
|
|
158
|
-
|
|
159
|
-
## Ejemplo: Insert
|
|
160
|
-
|
|
135
|
+
## Delete de Datos
|
|
161
136
|
```ts
|
|
162
|
-
|
|
163
|
-
|
|
137
|
+
await DB.Delete(prueba1())
|
|
138
|
+
.where(ORQ(prueba1.id, 2, 3))
|
|
139
|
+
.execute();
|
|
140
|
+
|
|
164
141
|
```
|
|
142
|
+
|
|
165
143
|
---
|
|
166
144
|
|
|
167
|
-
##
|
|
145
|
+
## Ejemplo de Uso
|
|
168
146
|
|
|
169
147
|
```ts
|
|
170
|
-
import { connecionLocal, DB, eq,
|
|
148
|
+
import { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } from "zormz";
|
|
171
149
|
|
|
172
150
|
const conexion: connecionLocal = {
|
|
173
151
|
database: "pruebamaster",
|
|
174
|
-
user: "root",
|
|
175
|
-
password: "",
|
|
176
|
-
port: 3306,
|
|
177
152
|
host: "localhost",
|
|
153
|
+
password: "pgZORMZ",
|
|
154
|
+
port: 5432,
|
|
155
|
+
user: "postgres",
|
|
178
156
|
};
|
|
179
157
|
|
|
180
|
-
getConexion("
|
|
158
|
+
getConexion("pg", conexion);
|
|
181
159
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
160
|
+
const prueba1 = defineTable("prueba1", {
|
|
161
|
+
id: int().Pk().$(),
|
|
162
|
+
valor: varchar(200).Default("hola").$(),
|
|
163
|
+
resultado: int().Default(0).$()
|
|
164
|
+
});
|
|
185
165
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
])
|
|
166
|
+
generateTable(prueba1(), prueba1.$columns);
|
|
167
|
+
|
|
168
|
+
async function pruebaData() {
|
|
169
|
+
await DB.Insert(prueba1(), [prueba1.valor, prueba1.resultado])
|
|
170
|
+
.Values([["hola mundo", 1], ["prueba", 0]])
|
|
191
171
|
.execute();
|
|
192
|
-
console.log(response);
|
|
193
172
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
173
|
+
const datos = await DB.select().from(prueba1()).execute();
|
|
174
|
+
console.log(datos);
|
|
175
|
+
|
|
176
|
+
await DB.Update(prueba1())
|
|
177
|
+
.set({ valor: "actualizado", resultado: 2 })
|
|
178
|
+
.where(eq(prueba1.id, 1))
|
|
197
179
|
.execute();
|
|
198
|
-
console.log(update);
|
|
199
180
|
|
|
200
|
-
|
|
201
|
-
.where(ORQ(
|
|
181
|
+
await DB.Delete(prueba1())
|
|
182
|
+
.where(ORQ(prueba1.id, 2, 3))
|
|
202
183
|
.execute();
|
|
203
|
-
console.log(eliminados);
|
|
204
184
|
}
|
|
205
185
|
|
|
206
|
-
pruebaData().catch(
|
|
207
|
-
console.log("error al cargar los datos");
|
|
208
|
-
});
|
|
186
|
+
pruebaData().catch(console.error);
|
|
209
187
|
|
|
210
188
|
```
|
|
211
189
|
|
|
212
190
|
---
|
|
213
191
|
|
|
214
|
-
##
|
|
215
|
-
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
|
-
|
|
192
|
+
## Notas
|
|
193
|
+
* ORM en version inicial con enfoque de tipado y autompletado
|
|
194
|
+
* Compatible con **MYSQL** y **PG**
|
|
195
|
+
* Preparado para extenderse
|
|
222
196
|
|
|
223
|
-
##
|
|
197
|
+
## Licencia
|
|
224
198
|
|
|
225
199
|
ISC © Yukio-kayaba
|
|
226
200
|
|
|
227
|
-
[](https://github.com/yukio-kayaba/)
|
|
@@ -1,3 +1,45 @@
|
|
|
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
|
+
type ColumnTypes =
|
|
12
|
+
| "varchar"
|
|
13
|
+
| "int"
|
|
14
|
+
| "double"
|
|
15
|
+
| "bool"
|
|
16
|
+
| "timestamp"
|
|
17
|
+
| "float"
|
|
18
|
+
| "money";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
|
|
22
|
+
typo: T;
|
|
23
|
+
pk?: boolean;
|
|
24
|
+
sqlz: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface VarcharType{
|
|
28
|
+
maxLenth?:number,
|
|
29
|
+
defaultData?:string,
|
|
30
|
+
requerido?:boolean
|
|
31
|
+
unique?:boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type IntType = {
|
|
35
|
+
defaultData?: number;
|
|
36
|
+
id?:boolean;
|
|
37
|
+
requerido?: boolean;
|
|
38
|
+
unique?: boolean;
|
|
39
|
+
unsingned:number;
|
|
40
|
+
autoIncrement?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
1
43
|
interface connecionLocal {
|
|
2
44
|
host: string;
|
|
3
45
|
port: number;
|
|
@@ -14,6 +56,7 @@ interface connecionRed {
|
|
|
14
56
|
connectionString: string;
|
|
15
57
|
}
|
|
16
58
|
type connectionDB = "mysql" | "pg";
|
|
59
|
+
declare function getTipoConexion(): connectionDB;
|
|
17
60
|
declare class BDconnection {
|
|
18
61
|
tipo: connectionDB;
|
|
19
62
|
pool: any;
|
|
@@ -31,23 +74,6 @@ declare class BDconnection {
|
|
|
31
74
|
*/
|
|
32
75
|
declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): Promise<void>;
|
|
33
76
|
declare function getRed(): BDconnection;
|
|
34
|
-
type ColumnTypes = "varchar" | "int" | "double" | "bool" | "timestamp" | "float" | "money";
|
|
35
|
-
type ColumnTypeMap = {
|
|
36
|
-
varchar: string;
|
|
37
|
-
double: number;
|
|
38
|
-
int: number;
|
|
39
|
-
bool: boolean;
|
|
40
|
-
timestamp: Date;
|
|
41
|
-
float: number;
|
|
42
|
-
money: number;
|
|
43
|
-
};
|
|
44
|
-
interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
|
|
45
|
-
typo: T;
|
|
46
|
-
id?: boolean;
|
|
47
|
-
maxLength?: number;
|
|
48
|
-
default?: ColumnTypeMap[T];
|
|
49
|
-
unique?: boolean;
|
|
50
|
-
}
|
|
51
77
|
type TableProxy<TCols> = {
|
|
52
78
|
(): string;
|
|
53
79
|
$columns: TCols;
|
|
@@ -132,16 +158,6 @@ declare class QueryBuilder {
|
|
|
132
158
|
execute(): Promise<number | any[] | undefined>;
|
|
133
159
|
}
|
|
134
160
|
|
|
135
|
-
interface ResultSetHeaderMysql {
|
|
136
|
-
fieldCount: number;
|
|
137
|
-
affectedRows: number;
|
|
138
|
-
insertId: number;
|
|
139
|
-
info: string;
|
|
140
|
-
serverStatus: number;
|
|
141
|
-
warningStatus: number;
|
|
142
|
-
changedRows: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
161
|
type valor = "ASC" | "DESC";
|
|
146
162
|
type Tipos = {
|
|
147
163
|
[clave: string]: valor;
|
|
@@ -357,4 +373,69 @@ declare const MENOR: (valor: string, valor2: string) => string;
|
|
|
357
373
|
*/
|
|
358
374
|
declare const CURRENT_TIMESTAMP: () => string;
|
|
359
375
|
|
|
360
|
-
|
|
376
|
+
declare class IntColumn {
|
|
377
|
+
private requerido;
|
|
378
|
+
private unique;
|
|
379
|
+
private autoIncrement;
|
|
380
|
+
private defaultData?;
|
|
381
|
+
private pk?;
|
|
382
|
+
private unsingned;
|
|
383
|
+
constructor();
|
|
384
|
+
Required(): this;
|
|
385
|
+
Pk(): this;
|
|
386
|
+
Unique(): this;
|
|
387
|
+
Unsingned(numeroPositivosInicio?: number): void;
|
|
388
|
+
AutoIncrement(): this;
|
|
389
|
+
Default(value: number): this;
|
|
390
|
+
withType({ defaultData, id, requerido, unique, autoIncrement }: IntType): this;
|
|
391
|
+
$(): ColumnDefinition;
|
|
392
|
+
}
|
|
393
|
+
declare function int(): IntColumn;
|
|
394
|
+
|
|
395
|
+
declare class Varchar {
|
|
396
|
+
private maxLenth;
|
|
397
|
+
private defaultData;
|
|
398
|
+
private requerido;
|
|
399
|
+
private unique;
|
|
400
|
+
constructor(cantidad?: number);
|
|
401
|
+
withType({ maxLenth, defaultData, requerido, unique, }: VarcharType): ColumnDefinition<undefined>;
|
|
402
|
+
Required(): this;
|
|
403
|
+
Unique(): this;
|
|
404
|
+
Default(textoDefecto: string): this;
|
|
405
|
+
$(): ColumnDefinition<undefined>;
|
|
406
|
+
}
|
|
407
|
+
declare function varchar(cantidad?: number): Varchar;
|
|
408
|
+
|
|
409
|
+
declare class BoolColumn {
|
|
410
|
+
private requerido;
|
|
411
|
+
private defaultData?;
|
|
412
|
+
required(): this;
|
|
413
|
+
default(value: boolean): this;
|
|
414
|
+
$(): ColumnDefinition;
|
|
415
|
+
}
|
|
416
|
+
declare function bool(): BoolColumn;
|
|
417
|
+
|
|
418
|
+
declare class Timestamp {
|
|
419
|
+
private requerido;
|
|
420
|
+
private defaultNow;
|
|
421
|
+
private onUpdateNow;
|
|
422
|
+
required(): this;
|
|
423
|
+
now(): this;
|
|
424
|
+
onUpdate(): this;
|
|
425
|
+
$(): ColumnDefinition<undefined>;
|
|
426
|
+
}
|
|
427
|
+
declare function timestamp(): Timestamp;
|
|
428
|
+
|
|
429
|
+
declare class Money {
|
|
430
|
+
private precision;
|
|
431
|
+
private scale;
|
|
432
|
+
private requerido;
|
|
433
|
+
private defaultData?;
|
|
434
|
+
constructor(presicion?: number, decimales?: number);
|
|
435
|
+
required(): this;
|
|
436
|
+
default(value: number): this;
|
|
437
|
+
$(): ColumnDefinition<undefined>;
|
|
438
|
+
}
|
|
439
|
+
declare function money(presicion?: number, decimales?: number): Money;
|
|
440
|
+
|
|
441
|
+
export { AND, BDconnection, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type TableProxy, type Tipos, Update, type Valores, type arrayData, type arrayDatas, bool, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, timestamp, type valor, varchar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
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
|
+
type ColumnTypes =
|
|
12
|
+
| "varchar"
|
|
13
|
+
| "int"
|
|
14
|
+
| "double"
|
|
15
|
+
| "bool"
|
|
16
|
+
| "timestamp"
|
|
17
|
+
| "float"
|
|
18
|
+
| "money";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
|
|
22
|
+
typo: T;
|
|
23
|
+
pk?: boolean;
|
|
24
|
+
sqlz: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface VarcharType{
|
|
28
|
+
maxLenth?:number,
|
|
29
|
+
defaultData?:string,
|
|
30
|
+
requerido?:boolean
|
|
31
|
+
unique?:boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type IntType = {
|
|
35
|
+
defaultData?: number;
|
|
36
|
+
id?:boolean;
|
|
37
|
+
requerido?: boolean;
|
|
38
|
+
unique?: boolean;
|
|
39
|
+
unsingned:number;
|
|
40
|
+
autoIncrement?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
1
43
|
interface connecionLocal {
|
|
2
44
|
host: string;
|
|
3
45
|
port: number;
|
|
@@ -14,6 +56,7 @@ interface connecionRed {
|
|
|
14
56
|
connectionString: string;
|
|
15
57
|
}
|
|
16
58
|
type connectionDB = "mysql" | "pg";
|
|
59
|
+
declare function getTipoConexion(): connectionDB;
|
|
17
60
|
declare class BDconnection {
|
|
18
61
|
tipo: connectionDB;
|
|
19
62
|
pool: any;
|
|
@@ -31,23 +74,6 @@ declare class BDconnection {
|
|
|
31
74
|
*/
|
|
32
75
|
declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): Promise<void>;
|
|
33
76
|
declare function getRed(): BDconnection;
|
|
34
|
-
type ColumnTypes = "varchar" | "int" | "double" | "bool" | "timestamp" | "float" | "money";
|
|
35
|
-
type ColumnTypeMap = {
|
|
36
|
-
varchar: string;
|
|
37
|
-
double: number;
|
|
38
|
-
int: number;
|
|
39
|
-
bool: boolean;
|
|
40
|
-
timestamp: Date;
|
|
41
|
-
float: number;
|
|
42
|
-
money: number;
|
|
43
|
-
};
|
|
44
|
-
interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
|
|
45
|
-
typo: T;
|
|
46
|
-
id?: boolean;
|
|
47
|
-
maxLength?: number;
|
|
48
|
-
default?: ColumnTypeMap[T];
|
|
49
|
-
unique?: boolean;
|
|
50
|
-
}
|
|
51
77
|
type TableProxy<TCols> = {
|
|
52
78
|
(): string;
|
|
53
79
|
$columns: TCols;
|
|
@@ -132,16 +158,6 @@ declare class QueryBuilder {
|
|
|
132
158
|
execute(): Promise<number | any[] | undefined>;
|
|
133
159
|
}
|
|
134
160
|
|
|
135
|
-
interface ResultSetHeaderMysql {
|
|
136
|
-
fieldCount: number;
|
|
137
|
-
affectedRows: number;
|
|
138
|
-
insertId: number;
|
|
139
|
-
info: string;
|
|
140
|
-
serverStatus: number;
|
|
141
|
-
warningStatus: number;
|
|
142
|
-
changedRows: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
161
|
type valor = "ASC" | "DESC";
|
|
146
162
|
type Tipos = {
|
|
147
163
|
[clave: string]: valor;
|
|
@@ -357,4 +373,69 @@ declare const MENOR: (valor: string, valor2: string) => string;
|
|
|
357
373
|
*/
|
|
358
374
|
declare const CURRENT_TIMESTAMP: () => string;
|
|
359
375
|
|
|
360
|
-
|
|
376
|
+
declare class IntColumn {
|
|
377
|
+
private requerido;
|
|
378
|
+
private unique;
|
|
379
|
+
private autoIncrement;
|
|
380
|
+
private defaultData?;
|
|
381
|
+
private pk?;
|
|
382
|
+
private unsingned;
|
|
383
|
+
constructor();
|
|
384
|
+
Required(): this;
|
|
385
|
+
Pk(): this;
|
|
386
|
+
Unique(): this;
|
|
387
|
+
Unsingned(numeroPositivosInicio?: number): void;
|
|
388
|
+
AutoIncrement(): this;
|
|
389
|
+
Default(value: number): this;
|
|
390
|
+
withType({ defaultData, id, requerido, unique, autoIncrement }: IntType): this;
|
|
391
|
+
$(): ColumnDefinition;
|
|
392
|
+
}
|
|
393
|
+
declare function int(): IntColumn;
|
|
394
|
+
|
|
395
|
+
declare class Varchar {
|
|
396
|
+
private maxLenth;
|
|
397
|
+
private defaultData;
|
|
398
|
+
private requerido;
|
|
399
|
+
private unique;
|
|
400
|
+
constructor(cantidad?: number);
|
|
401
|
+
withType({ maxLenth, defaultData, requerido, unique, }: VarcharType): ColumnDefinition<undefined>;
|
|
402
|
+
Required(): this;
|
|
403
|
+
Unique(): this;
|
|
404
|
+
Default(textoDefecto: string): this;
|
|
405
|
+
$(): ColumnDefinition<undefined>;
|
|
406
|
+
}
|
|
407
|
+
declare function varchar(cantidad?: number): Varchar;
|
|
408
|
+
|
|
409
|
+
declare class BoolColumn {
|
|
410
|
+
private requerido;
|
|
411
|
+
private defaultData?;
|
|
412
|
+
required(): this;
|
|
413
|
+
default(value: boolean): this;
|
|
414
|
+
$(): ColumnDefinition;
|
|
415
|
+
}
|
|
416
|
+
declare function bool(): BoolColumn;
|
|
417
|
+
|
|
418
|
+
declare class Timestamp {
|
|
419
|
+
private requerido;
|
|
420
|
+
private defaultNow;
|
|
421
|
+
private onUpdateNow;
|
|
422
|
+
required(): this;
|
|
423
|
+
now(): this;
|
|
424
|
+
onUpdate(): this;
|
|
425
|
+
$(): ColumnDefinition<undefined>;
|
|
426
|
+
}
|
|
427
|
+
declare function timestamp(): Timestamp;
|
|
428
|
+
|
|
429
|
+
declare class Money {
|
|
430
|
+
private precision;
|
|
431
|
+
private scale;
|
|
432
|
+
private requerido;
|
|
433
|
+
private defaultData?;
|
|
434
|
+
constructor(presicion?: number, decimales?: number);
|
|
435
|
+
required(): this;
|
|
436
|
+
default(value: number): this;
|
|
437
|
+
$(): ColumnDefinition<undefined>;
|
|
438
|
+
}
|
|
439
|
+
declare function money(presicion?: number, decimales?: number): Money;
|
|
440
|
+
|
|
441
|
+
export { AND, BDconnection, CURRENT_TIMESTAMP, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type TableProxy, type Tipos, Update, type Valores, type arrayData, type arrayDatas, bool, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, timestamp, type valor, varchar };
|