zormz 1.4.1 → 1.4.2

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
@@ -7,17 +7,17 @@ Permite conectarse a una base de datos, definir tablas desde TypeScript con auto
7
7
 
8
8
  ## Características
9
9
 
10
- * Compatible con **ESM** y **CommonJS**
11
- * Tipado completo en **TypeScript**
12
- * Builder con sintaxis encadenada: `select().from().where().execute()`
13
- * Insert múltiple con arrays
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
19
- * Sin dependencias pesadas
20
- * Fácil de extender
10
+ - Compatible con **ESM** y **CommonJS**
11
+ - Tipado completo en **TypeScript**
12
+ - Builder con sintaxis encadenada: `select().from().where().execute()`
13
+ - Insert múltiple con arrays
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
19
+ - Sin dependencias pesadas
20
+ - Fácil de extender
21
21
 
22
22
  ---
23
23
 
@@ -29,20 +29,43 @@ npm install zormz
29
29
  ```
30
30
 
31
31
  ## Uso basico
32
- ### importacion ESM
33
- ```ts
34
32
 
35
- import { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } from "zormz";
33
+ ### importacion ESM
36
34
 
35
+ ```ts
36
+ import {
37
+ connecionLocal,
38
+ getConexion,
39
+ defineTable,
40
+ generateTable,
41
+ int,
42
+ varchar,
43
+ DB,
44
+ eq,
45
+ ORQ,
46
+ } from "zormz";
37
47
  ```
48
+
38
49
  ### importacion COMMONJS
39
50
 
40
51
  ```ts
41
- const { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } = require("zormz");
42
-
52
+ const {
53
+ connecionLocal,
54
+ getConexion,
55
+ defineTable,
56
+ generateTable,
57
+ int,
58
+ varchar,
59
+ DB,
60
+ eq,
61
+ ORQ,
62
+ } = require("zormz");
43
63
  ```
64
+
44
65
  ## Conexion a la base de datos
66
+
45
67
  ### MYSQL
68
+
46
69
  ```ts
47
70
  const conexionMysql: connecionLocal = {
48
71
  database: "pruebas",
@@ -53,15 +76,15 @@ const conexionMysql: connecionLocal = {
53
76
  };
54
77
 
55
78
  getConexion("mysql", conexionMysql);
56
-
57
79
  ```
58
80
 
59
81
  ### PG
82
+
60
83
  ```ts
61
84
  //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"
64
- }
85
+ const conexion2: connecionRed = {
86
+ connectionString: "direccion",
87
+ };
65
88
 
66
89
  const conexion: connecionLocal = {
67
90
  database: "pruebamaster",
@@ -72,10 +95,9 @@ const conexion: connecionLocal = {
72
95
  };
73
96
 
74
97
  getConexion("pg", conexion);
75
-
76
98
  ```
77
99
 
78
- ## Definicion de Tablas
100
+ ## Definicion de Tablas
79
101
 
80
102
  ```ts
81
103
  export const prueba1 = defineTable("prueba1", {
@@ -83,11 +105,12 @@ export const prueba1 = defineTable("prueba1", {
83
105
  valor: varchar(200).Default("hola").$(),
84
106
  resultado: int().Default(0).$(),
85
107
  fechaRegistro: timestamp().required().now().$(),
86
- fechaUpdate: timestamp().required().now().onUpdate().$()
108
+ fechaUpdate: timestamp().required().now().onUpdate().$(),
87
109
  });
88
-
89
110
  ```
111
+
90
112
  o
113
+
91
114
  ```ts
92
115
  export function generateTables() {
93
116
  return {
@@ -98,7 +121,7 @@ export function generateTables() {
98
121
  dni: varchar(9).$(),
99
122
  rol: varchar(50).$(),
100
123
  diastrabajo: varchar(200).Default("sabado - domingo").$(),
101
- activo: bool().default(true).$(),
124
+ estado: varchar().Check(["pendiente", "completado", "rechazado"]).$(),
102
125
  }),
103
126
  permisos: defineTable("permisos", {
104
127
  idpermiso: int().Pk().$(),
@@ -116,21 +139,27 @@ export function generateTables() {
116
139
  ```
117
140
 
118
141
  ### Notas importantes
119
- * **.pk()** define la columna como clave primaria
120
- * **.Default()** entrega un valor por defecto
121
- * **.$()** finaliza la definicion y entrega un valor compatible con *$columns*
122
- * **.required()** Indica que los valores de la fila no podran ser null, si o si un valor obligatorio
123
- * **.now()** Solo esta disponible para timestamp , indica fecha automatica de registra
124
- * **.onUpdate()** Tomara la fecha actual cada ves que se haga un update
142
+
143
+ - **.pk()** define la columna como clave primaria
144
+ - **.Default()** entrega un valor por defecto
145
+ - **.$()** finaliza la definicion y entrega un valor compatible con _$columns_
146
+ - **.required()** Indica que los valores de la fila no podran ser null, si o si un valor obligatorio
147
+ - **.now()** Solo esta disponible para timestamp , indica fecha automatica de registra
148
+ - **.onUpdate()** Tomara la fecha actual cada ves que se haga un update
149
+ - **.Check()** Solo para varchar , puedes decirle que valores esta obligado a recibir y no otros
150
+
125
151
  ## Generacion de tablas
152
+
126
153
  ```ts
127
- generateTable(prueba1(), prueba1.$columns);
154
+ generateTable(prueba1(), prueba1.$columns,true);//true para ver la definicion
128
155
  ```
156
+
129
157
  Esto crea la tabla en la base de datos respetando tipos, claves primarias y valores por defecto.
130
158
 
131
159
  ---
132
160
 
133
161
  ## Eliminar tablas
162
+
134
163
  ```ts
135
164
  await dropTable(prueba4());
136
165
  ```
@@ -139,10 +168,14 @@ await dropTable(prueba4());
139
168
 
140
169
  ```ts
141
170
  await DB.Insert(prueba1(), [prueba1.valor, prueba1.resultado])
142
- .Values([["hola mundo", 1], ["prueba", 0]])
171
+ .Values([
172
+ ["hola mundo", 1],
173
+ ["prueba", 0],
174
+ ])
175
+ .Returning(prueba1.id)
143
176
  .execute();
144
-
145
177
  ```
178
+
146
179
  ---
147
180
 
148
181
  ## Select de Datos
@@ -151,67 +184,82 @@ await DB.Insert(prueba1(), [prueba1.valor, prueba1.resultado])
151
184
  const datos = await DB.select()
152
185
  .from(prueba1())
153
186
  .where(eq(prueba1.id, 1))
154
- .execute();
155
-
187
+ .execute(true);
156
188
  ```
189
+
157
190
  ---
158
191
 
159
192
  ## Update de Datos
160
- ### .set() Recibe un objeto con clave valor de las tablas o un array con UP
193
+
194
+ ### .set() Recibe un objeto con clave valor de las tablas o un array con UP
195
+
161
196
  ```ts
162
197
  await DB.Update(prueba1())
163
198
  .set({ valor: "nuevo valor", resultado: 2 })
164
199
  .where(eq(prueba1.id, 1))
165
200
  .execute();
166
-
167
201
  ```
202
+
168
203
  o
204
+
169
205
  ```ts
170
- //Usar la funcion UP
171
- const response = await DB.Update(producto())
172
- .set([UP(producto.stockactual, `${producto.stockactual} - 4`, true)])
173
- .where(eq(producto.idproducto, 4))
174
- .execute();
175
-
206
+ //Usar la funcion UP
207
+ const response = await DB.Update(producto())
208
+ .set([UP(producto.stockactual, `${producto.stockactual} - 4`, true)])
209
+ .where(eq(producto.idproducto, 4))
210
+ .execute();
176
211
  ```
177
212
 
178
213
  ---
214
+
179
215
  ## Delete de Datos
216
+
180
217
  ```ts
181
218
  await DB.Delete(prueba1())
182
219
  .where(ORQ(prueba1.id, 2, 3))
183
220
  .execute();
184
-
185
221
  ```
222
+
186
223
  ## JOINS
224
+
187
225
  ```ts
188
226
  const { detallespermisos, colaborador, permisos } = generateTables();
189
227
 
190
- const response = await DB.Select([
191
- detallespermisos.iddetallepermiso,
192
- colaborador.nombrecompleto,
193
- colaborador.dni,
194
- permisos.nombre,
195
- permisos.estado,
196
- ])
197
- .from(detallespermisos())
198
- .innerJOIN(
199
- colaborador(),
200
- eq(colaborador.idcolaborador, detallespermisos.idcolaborador, false),
201
- )
202
- .innerJOIN(
203
- permisos(),
204
- eq(permisos.idpermiso, detallespermisos.idppermiso, false),
205
- )
206
- .execute();
207
-
228
+ const response = await DB.Select([
229
+ detallespermisos.iddetallepermiso,
230
+ colaborador.nombrecompleto,
231
+ colaborador.dni,
232
+ permisos.nombre,
233
+ permisos.estado,
234
+ ])
235
+ .from(detallespermisos())
236
+ .innerJOIN(
237
+ colaborador(),
238
+ eq(colaborador.idcolaborador, detallespermisos.idcolaborador, false),
239
+ )
240
+ .innerJOIN(
241
+ permisos(),
242
+ eq(permisos.idpermiso, detallespermisos.idppermiso, false),
243
+ )
244
+ .execute();
208
245
  ```
246
+
209
247
  ---
210
248
 
211
- ## Ejemplo de Uso
249
+ ## Ejemplo de Uso
212
250
 
213
251
  ```ts
214
- import { connecionLocal, getConexion, defineTable, generateTable, int, varchar, DB, eq, ORQ } from "zormz";
252
+ import {
253
+ connecionLocal,
254
+ getConexion,
255
+ defineTable,
256
+ generateTable,
257
+ int,
258
+ varchar,
259
+ DB,
260
+ eq,
261
+ ORQ,
262
+ } from "zormz";
215
263
 
216
264
  const conexion: connecionLocal = {
217
265
  database: "pruebamaster",
@@ -228,14 +276,17 @@ getConexion("pg", conexion);
228
276
  const prueba1 = defineTable("prueba1", {
229
277
  id: int().Pk().$(),
230
278
  valor: varchar(200).Default("hola").$(),
231
- resultado: int().Default(0).$()
279
+ resultado: int().Default(0).$(),
232
280
  });
233
281
 
234
282
  generateTable(prueba1(), prueba1.$columns);
235
283
 
236
284
  async function pruebaData() {
237
285
  await DB.Insert(prueba1(), [prueba1.valor, prueba1.resultado])
238
- .Values([["hola mundo", 1], ["prueba", 0]])
286
+ .Values([
287
+ ["hola mundo", 1],
288
+ ["prueba", 0],
289
+ ])
239
290
  .execute();
240
291
 
241
292
  const datos = await DB.select().from(prueba1()).execute();
@@ -252,19 +303,20 @@ async function pruebaData() {
252
303
  }
253
304
 
254
305
  pruebaData().catch(console.error);
255
-
256
306
  ```
257
307
 
258
308
  ---
259
309
 
260
310
  ## Notas
261
- * ORM en version inicial con enfoque de tipado y autompletado
262
- * Compatible con **MYSQL** y **PG**
263
- * Preparado para extenderse
264
- * Las versiones +1.3.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
265
- * version estable 1.4.0
311
+
312
+ - ORM en version inicial con enfoque de tipado y autompletado
313
+ - Compatible con **MYSQL** y **PG**
314
+ - Preparado para extenderse
315
+ - Las versiones +1.3.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
316
+ - version estable 1.4.0
317
+
266
318
  ## Licencia
267
319
 
268
320
  ISC © Yukio-kayaba
269
321
 
270
- [![GitHub](https://img.shields.io/badge/GitHub-Sigue%20me-black?logo=github)](https://github.com/yukio-kayaba/)
322
+ [![GitHub](https://img.shields.io/badge/GitHub-Sigue%20me-black?logo=github)](https://github.com/yukio-kayaba/)
package/dist/index.d.mts CHANGED
@@ -12,6 +12,7 @@ interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
12
12
  typo: T;
13
13
  pk?: boolean;
14
14
  sqlz: string;
15
+ check?: string
15
16
  }
16
17
 
17
18
  interface VarcharType{
@@ -83,25 +84,17 @@ type TableProxy<TCols> = {
83
84
  * @param {string} tableName
84
85
  * @param {string} columns
85
86
  * @example
86
- * export const productosPrueba = defineTable("productosPrueba",{
87
- * id:{typo:"int",id:true},
88
- dato: {
89
- typo:"varchar",
90
- maxLength:200,
91
- default:"hola mundo"
92
- },
93
- edad: {
94
- typo:"int",
95
- default: 0,
96
- },
97
- apellido : {
98
- typo:"varchar",
99
- }
87
+ * export const categorias = defineTable("categorias", {
88
+ idcategoria: int().Pk().$(),
89
+ nombrecategoria: varchar(100).Check(['disponible','data']).Required().$(),
90
+ descripcion: varchar(250).$(),
91
+ estado: bool().default(true).$(),
92
+ })
100
93
  * });
101
94
  * @returns
102
95
  */
103
96
  declare function defineTable<T extends Record<string, ColumnDefinition>>(tableName: string, columns: T): TableProxy<T>;
104
- declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T): Promise<void>;
97
+ declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T, seeSQL?: boolean): Promise<void>;
105
98
  declare function dropTable(nombreTabla: string): Promise<void>;
106
99
 
107
100
  declare class DeleteR {
@@ -131,7 +124,7 @@ declare class QueryBuilder {
131
124
  private tabla;
132
125
  private parametros;
133
126
  private valores;
134
- private valorRetorno;
127
+ private returning;
135
128
  private conexion;
136
129
  /**
137
130
  * @throws {Error} Si la consulta es vacía.
@@ -154,7 +147,8 @@ declare class QueryBuilder {
154
147
  * @returns
155
148
  */
156
149
  Values(values: arrayData | arrayDatas): this;
157
- execute(see?: boolean): Promise<number | any[] | undefined>;
150
+ Returning(idRetorno: string): this;
151
+ execute(see?: boolean): Promise<any[] | undefined>;
158
152
  }
159
153
 
160
154
  type valor = "ASC" | "DESC";
@@ -392,9 +386,11 @@ declare class IntColumn {
392
386
  private defaultData?;
393
387
  private pk?;
394
388
  private unsingned;
389
+ private comentario;
395
390
  constructor();
396
391
  Required(): this;
397
392
  Pk(): this;
393
+ Comment(comentario: string): this;
398
394
  Unique(): this;
399
395
  Unsingned(numeroPositivosInicio?: number): this;
400
396
  AutoIncrement(): this;
@@ -409,9 +405,23 @@ declare class Varchar {
409
405
  private defaultData;
410
406
  private requerido;
411
407
  private unique;
408
+ private enum;
409
+ private campo;
410
+ private comentarios;
412
411
  constructor(cantidad?: number);
413
412
  withType({ maxLenth, defaultData, requerido, unique, }: VarcharType): ColumnDefinition<ColumnTypes>;
413
+ /**
414
+ *
415
+ * @param {string} campo
416
+ * @param {string[]} datos
417
+ * @example
418
+ * Check("example", ["operativo","denegado","revisando"])
419
+ *
420
+ * @returns
421
+ */
422
+ Check(datos: (string)[]): this;
414
423
  Required(): this;
424
+ Comment(comentario: string): this;
415
425
  Unique(): this;
416
426
  Default(textoDefecto: string): this;
417
427
  $(): ColumnDefinition<ColumnTypes>;
@@ -421,7 +431,9 @@ declare function varchar(cantidad?: number): Varchar;
421
431
  declare class BoolColumn {
422
432
  private requerido;
423
433
  private defaultData?;
434
+ private comentario;
424
435
  required(): this;
436
+ Comment(comentario: string): this;
425
437
  default(value: boolean): this;
426
438
  $(): ColumnDefinition;
427
439
  }
@@ -431,7 +443,9 @@ declare class Timestamp {
431
443
  private requerido;
432
444
  private defaultNow;
433
445
  private onUpdateNow;
446
+ private comentario;
434
447
  required(): this;
448
+ comment(comentario: string): this;
435
449
  now(): this;
436
450
  onUpdate(): this;
437
451
  $(): ColumnDefinition<ColumnTypes>;
@@ -443,9 +457,11 @@ declare class Money {
443
457
  private scale;
444
458
  private requerido;
445
459
  private defaultData?;
460
+ private comentario;
446
461
  constructor(presicion?: number, decimales?: number);
447
462
  required(): this;
448
463
  default(value: number): this;
464
+ comment(comentario: string): this;
449
465
  $(): ColumnDefinition<ColumnTypes>;
450
466
  }
451
467
  declare function money(presicion?: number, decimales?: number): Money;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ interface ColumnDefinition<T extends ColumnTypes = ColumnTypes> {
12
12
  typo: T;
13
13
  pk?: boolean;
14
14
  sqlz: string;
15
+ check?: string
15
16
  }
16
17
 
17
18
  interface VarcharType{
@@ -83,25 +84,17 @@ type TableProxy<TCols> = {
83
84
  * @param {string} tableName
84
85
  * @param {string} columns
85
86
  * @example
86
- * export const productosPrueba = defineTable("productosPrueba",{
87
- * id:{typo:"int",id:true},
88
- dato: {
89
- typo:"varchar",
90
- maxLength:200,
91
- default:"hola mundo"
92
- },
93
- edad: {
94
- typo:"int",
95
- default: 0,
96
- },
97
- apellido : {
98
- typo:"varchar",
99
- }
87
+ * export const categorias = defineTable("categorias", {
88
+ idcategoria: int().Pk().$(),
89
+ nombrecategoria: varchar(100).Check(['disponible','data']).Required().$(),
90
+ descripcion: varchar(250).$(),
91
+ estado: bool().default(true).$(),
92
+ })
100
93
  * });
101
94
  * @returns
102
95
  */
103
96
  declare function defineTable<T extends Record<string, ColumnDefinition>>(tableName: string, columns: T): TableProxy<T>;
104
- declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T): Promise<void>;
97
+ declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T, seeSQL?: boolean): Promise<void>;
105
98
  declare function dropTable(nombreTabla: string): Promise<void>;
106
99
 
107
100
  declare class DeleteR {
@@ -131,7 +124,7 @@ declare class QueryBuilder {
131
124
  private tabla;
132
125
  private parametros;
133
126
  private valores;
134
- private valorRetorno;
127
+ private returning;
135
128
  private conexion;
136
129
  /**
137
130
  * @throws {Error} Si la consulta es vacía.
@@ -154,7 +147,8 @@ declare class QueryBuilder {
154
147
  * @returns
155
148
  */
156
149
  Values(values: arrayData | arrayDatas): this;
157
- execute(see?: boolean): Promise<number | any[] | undefined>;
150
+ Returning(idRetorno: string): this;
151
+ execute(see?: boolean): Promise<any[] | undefined>;
158
152
  }
159
153
 
160
154
  type valor = "ASC" | "DESC";
@@ -392,9 +386,11 @@ declare class IntColumn {
392
386
  private defaultData?;
393
387
  private pk?;
394
388
  private unsingned;
389
+ private comentario;
395
390
  constructor();
396
391
  Required(): this;
397
392
  Pk(): this;
393
+ Comment(comentario: string): this;
398
394
  Unique(): this;
399
395
  Unsingned(numeroPositivosInicio?: number): this;
400
396
  AutoIncrement(): this;
@@ -409,9 +405,23 @@ declare class Varchar {
409
405
  private defaultData;
410
406
  private requerido;
411
407
  private unique;
408
+ private enum;
409
+ private campo;
410
+ private comentarios;
412
411
  constructor(cantidad?: number);
413
412
  withType({ maxLenth, defaultData, requerido, unique, }: VarcharType): ColumnDefinition<ColumnTypes>;
413
+ /**
414
+ *
415
+ * @param {string} campo
416
+ * @param {string[]} datos
417
+ * @example
418
+ * Check("example", ["operativo","denegado","revisando"])
419
+ *
420
+ * @returns
421
+ */
422
+ Check(datos: (string)[]): this;
414
423
  Required(): this;
424
+ Comment(comentario: string): this;
415
425
  Unique(): this;
416
426
  Default(textoDefecto: string): this;
417
427
  $(): ColumnDefinition<ColumnTypes>;
@@ -421,7 +431,9 @@ declare function varchar(cantidad?: number): Varchar;
421
431
  declare class BoolColumn {
422
432
  private requerido;
423
433
  private defaultData?;
434
+ private comentario;
424
435
  required(): this;
436
+ Comment(comentario: string): this;
425
437
  default(value: boolean): this;
426
438
  $(): ColumnDefinition;
427
439
  }
@@ -431,7 +443,9 @@ declare class Timestamp {
431
443
  private requerido;
432
444
  private defaultNow;
433
445
  private onUpdateNow;
446
+ private comentario;
434
447
  required(): this;
448
+ comment(comentario: string): this;
435
449
  now(): this;
436
450
  onUpdate(): this;
437
451
  $(): ColumnDefinition<ColumnTypes>;
@@ -443,9 +457,11 @@ declare class Money {
443
457
  private scale;
444
458
  private requerido;
445
459
  private defaultData?;
460
+ private comentario;
446
461
  constructor(presicion?: number, decimales?: number);
447
462
  required(): this;
448
463
  default(value: number): this;
464
+ comment(comentario: string): this;
449
465
  $(): ColumnDefinition<ColumnTypes>;
450
466
  }
451
467
  declare function money(presicion?: number, decimales?: number): Money;
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ module.exports = __toCommonJS(index_exports);
73
73
  var Validator = class {
74
74
  };
75
75
  Validator.isValidTable = (val) => /^(?![0-9_])[a-z][a-z0-9_]{0,62}$/.test(val);
76
- Validator.isValidColumn = (val) => /^[a-z][a-z0-9_]{0,62}$/.test(val);
76
+ Validator.isValidColumn = (val) => /^[a-zA-Z][a-zA-Z0-9]{0,62}$/.test(val);
77
77
  Validator.isValidUsername = (val) => /^[a-zA-Z0-9\-_]+$/.test(val);
78
78
  var RESERVED_WORDS = /* @__PURE__ */ new Set([
79
79
  "select",
@@ -217,7 +217,7 @@ function defineTable(tableName, columns) {
217
217
  const fn = () => tableName;
218
218
  if (!Validator.isValidTable(tableName)) {
219
219
  throw new Error(
220
- "El nombre de la tabla no puede contener mayusculas o caracteres especiales"
220
+ "El nombre de la tabla no puede contener mayusculas o caracteres especiales : " + tableName
221
221
  );
222
222
  }
223
223
  if (RESERVED_WORDS.has(tableName)) {
@@ -244,7 +244,7 @@ function defineTable(tableName, columns) {
244
244
  if (prop === "toString") return () => tableName;
245
245
  if (prop === "valueOf") return () => tableName;
246
246
  if (prop in columns) {
247
- return `${tableName}.${prop.toString()}`;
247
+ return tipoConexionZORMZ3691 === "mysql" ? `${tableName}.\`${prop.toString()}\` ` : `${tableName}."${prop.toString()}" `;
248
248
  }
249
249
  return void 0;
250
250
  },
@@ -266,14 +266,15 @@ function defineTable(tableName, columns) {
266
266
  });
267
267
  return proxy;
268
268
  }
269
- async function generateTable(tabla, columns) {
269
+ async function generateTable(tabla, columns, seeSQL = false) {
270
270
  let queries = "";
271
271
  let columnDefs = [];
272
+ let cheksOut = [];
272
273
  let sql = "";
273
274
  let id = false;
274
275
  for (const columnName in columns) {
275
276
  const col = columns[columnName];
276
- sql = ` ${columnName} `;
277
+ sql = tipoConexionZORMZ3691 === "mysql" ? `\`${columnName}\` ` : `"${columnName}" `;
277
278
  if (!col.typo) {
278
279
  throw new Error(`La columna ${columnName} no tiene el tipo definido`);
279
280
  }
@@ -287,16 +288,28 @@ async function generateTable(tabla, columns) {
287
288
  id = col.pk === true ? true : false;
288
289
  sql += col.sqlz;
289
290
  columnDefs.push(sql);
291
+ if (col.check !== void 0) {
292
+ cheksOut.push(
293
+ `CONSTRAINT chk_${columnName} CHECK (${columnName} IN ( ${col.check}))`
294
+ );
295
+ }
290
296
  }
291
297
  queries += `CREATE TABLE IF NOT EXISTS ${tabla} (
292
298
  `;
293
299
  queries += columnDefs.join(", \n");
300
+ if (cheksOut.length > 0) {
301
+ queries += ",\n";
302
+ }
303
+ queries += cheksOut.join(",\n");
294
304
  queries += ");";
295
305
  if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
296
306
  throw new Error(
297
307
  "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
298
308
  );
299
309
  }
310
+ if (seeSQL) {
311
+ console.log(queries);
312
+ }
300
313
  if (tipoConexionZORMZ3691 === "mysql") {
301
314
  const response = await conexionZORMZ3691.executeConsulta({
302
315
  query: queries,
@@ -417,7 +430,6 @@ var QueryBuilder = class {
417
430
  this.tabla = tabla;
418
431
  this.parametros = parametros;
419
432
  this.valores = [];
420
- this.valorRetorno = null;
421
433
  this.conexion = conexion;
422
434
  }
423
435
  /**
@@ -438,8 +450,11 @@ var QueryBuilder = class {
438
450
  this.valores = values;
439
451
  return this;
440
452
  }
453
+ Returning(idRetorno) {
454
+ this.returning = idRetorno;
455
+ return this;
456
+ }
441
457
  async execute(see = false) {
442
- this.valorRetorno = 1;
443
458
  let query1 = `INSERT INTO ${this.tabla} `;
444
459
  let param = "";
445
460
  let arrayArrays = false;
@@ -501,15 +516,26 @@ var QueryBuilder = class {
501
516
  valores: arrayArrays ? [this.valores] : this.valores,
502
517
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
503
518
  });
504
- return respuesta.insertId;
519
+ let response = [];
520
+ if (this.returning !== void 0) {
521
+ for (let i = 0; i < this.valores.length; i++) {
522
+ response.push(respuesta.insertId + i);
523
+ }
524
+ }
525
+ return response;
505
526
  } else if (this.conexion.tipo === "pg") {
506
- query += " RETURNING id ";
527
+ if (this.returning !== void 0)
528
+ query += ` RETURNING ${this.returning} `;
507
529
  const respuesta = await this.conexion.executeConsulta({
508
530
  query,
509
531
  valores: this.valores,
510
532
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
511
533
  });
512
- return respuesta.rows;
534
+ let response = [];
535
+ if (respuesta.rows !== void 0) {
536
+ response = respuesta.rows.map((obj) => Object.values(obj)[0]);
537
+ }
538
+ return response;
513
539
  }
514
540
  }
515
541
  };
@@ -755,7 +781,7 @@ var Update = class {
755
781
  }
756
782
  } else if (validate) {
757
783
  valores.forEach((valors) => {
758
- valor += eq(valors.campoUp, valors.newCampoUp, !valors.dataTable);
784
+ valor += eq(valors.campoUp.replace(`${this.nombreTabla}.`, ""), valors.newCampoUp.replace(`${this.nombreTabla}.`, ""), !valors.dataTable);
759
785
  valor += ",";
760
786
  });
761
787
  }
@@ -786,7 +812,7 @@ var Update = class {
786
812
  async execute(seeQuery = false) {
787
813
  const query = `UPDATE ${this.nombreTabla} SET ${this.valores} ${this.condicion};`;
788
814
  if (seeQuery) {
789
- console.log(seeQuery);
815
+ console.log(query);
790
816
  }
791
817
  const respuesta = await this.conexion.executeConsulta({
792
818
  query,
@@ -795,9 +821,7 @@ var Update = class {
795
821
  if (this.conexion.tipo === "mysql") {
796
822
  return respuesta.affectedRows;
797
823
  } else {
798
- return {
799
- resultado: respuesta.rowCount
800
- };
824
+ return respuesta.rowCount;
801
825
  }
802
826
  }
803
827
  };
@@ -847,6 +871,7 @@ var IntColumn = class {
847
871
  this.unique = false;
848
872
  this.autoIncrement = false;
849
873
  this.unsingned = { uso: false, valor: 0 };
874
+ this.comentario = "";
850
875
  }
851
876
  Required() {
852
877
  this.requerido = true;
@@ -857,6 +882,10 @@ var IntColumn = class {
857
882
  this.pk = true;
858
883
  return this;
859
884
  }
885
+ Comment(comentario) {
886
+ this.comentario = comentario;
887
+ return this;
888
+ }
860
889
  Unique() {
861
890
  this.unique = true;
862
891
  return this;
@@ -915,6 +944,9 @@ var IntColumn = class {
915
944
  parts.push(`DEFAULT ${this.defaultData}`);
916
945
  }
917
946
  if (this.unique) parts.push("UNIQUE");
947
+ if (db === "mysql" && this.comentario.length > 2) {
948
+ parts.push(` COMMENT '${this.comentario}' `);
949
+ }
918
950
  const valor = {
919
951
  pk: false,
920
952
  typo: "int",
@@ -934,6 +966,9 @@ var Varchar = class {
934
966
  this.defaultData = "";
935
967
  this.requerido = false;
936
968
  this.unique = false;
969
+ this.enum = "";
970
+ this.campo = "";
971
+ this.comentarios = "";
937
972
  this.maxLenth = cantidad;
938
973
  }
939
974
  withType({
@@ -947,10 +982,27 @@ var Varchar = class {
947
982
  this.unique = unique;
948
983
  return this.Default(defaultData).$();
949
984
  }
985
+ /**
986
+ *
987
+ * @param {string} campo
988
+ * @param {string[]} datos
989
+ * @example
990
+ * Check("example", ["operativo","denegado","revisando"])
991
+ *
992
+ * @returns
993
+ */
994
+ Check(datos) {
995
+ this.enum = datos.map((caracter) => `'${caracter}'`).join(",");
996
+ return this;
997
+ }
950
998
  Required() {
951
999
  this.requerido = true;
952
1000
  return this;
953
1001
  }
1002
+ Comment(comentario) {
1003
+ this.comentarios = comentario;
1004
+ return this;
1005
+ }
954
1006
  Unique() {
955
1007
  this.unique = true;
956
1008
  return this;
@@ -965,11 +1017,16 @@ var Varchar = class {
965
1017
  return this;
966
1018
  }
967
1019
  $() {
968
- let sqlz = `VARCHAR(${this.maxLenth}) ${this.requerido ? "NOT NULL" : "NULL"} ${this.defaultData.length > 0 ? ` DEFAULT ${this.defaultData} ` : " "} ${this.unique ? " UNIQUE" : " "} `;
1020
+ let sqlz = `VARCHAR(${this.maxLenth}) ${this.requerido ? "NOT NULL" : "NULL"} ${this.defaultData.length > 0 ? ` DEFAULT ${this.defaultData} ` : " "} ${this.unique ? " UNIQUE" : " "}`;
1021
+ const db = getTipoConexion();
1022
+ if (db === "mysql" && this.comentarios.length > 2) {
1023
+ sqlz += ` COMMENT '${this.comentarios}' `;
1024
+ }
969
1025
  const response = {
970
1026
  typo: "varchar",
971
1027
  pk: false,
972
- sqlz
1028
+ sqlz,
1029
+ check: this.enum.length > 2 ? this.enum : void 0
973
1030
  };
974
1031
  return response;
975
1032
  }
@@ -982,11 +1039,16 @@ function varchar(cantidad = 100) {
982
1039
  var BoolColumn = class {
983
1040
  constructor() {
984
1041
  this.requerido = false;
1042
+ this.comentario = "";
985
1043
  }
986
1044
  required() {
987
1045
  this.requerido = true;
988
1046
  return this;
989
1047
  }
1048
+ Comment(comentario) {
1049
+ this.comentario = comentario;
1050
+ return this;
1051
+ }
990
1052
  default(value) {
991
1053
  this.defaultData = value;
992
1054
  return this;
@@ -1001,6 +1063,9 @@ var BoolColumn = class {
1001
1063
  `DEFAULT ${db === "mysql" ? this.defaultData ? 1 : 0 : this.defaultData}`
1002
1064
  );
1003
1065
  }
1066
+ if (db === "mysql" && this.comentario.length > 2) {
1067
+ parts.push(` COMMENT '${this.comentario}' `);
1068
+ }
1004
1069
  const response = {
1005
1070
  typo: "bool",
1006
1071
  pk: false,
@@ -1019,11 +1084,16 @@ var Timestamp = class {
1019
1084
  this.requerido = false;
1020
1085
  this.defaultNow = false;
1021
1086
  this.onUpdateNow = false;
1087
+ this.comentario = "";
1022
1088
  }
1023
1089
  required() {
1024
1090
  this.requerido = true;
1025
1091
  return this;
1026
1092
  }
1093
+ comment(comentario) {
1094
+ this.comentario = comentario;
1095
+ return this;
1096
+ }
1027
1097
  now() {
1028
1098
  this.defaultNow = true;
1029
1099
  return this;
@@ -1043,6 +1113,9 @@ var Timestamp = class {
1043
1113
  if (this.onUpdateNow && db === "mysql") {
1044
1114
  parts.push("ON UPDATE CURRENT_TIMESTAMP");
1045
1115
  }
1116
+ if (db === "mysql" && this.comentario.length > 2) {
1117
+ parts.push(` COMMENT '${this.comentario}' `);
1118
+ }
1046
1119
  const response = {
1047
1120
  typo: "timestamp",
1048
1121
  pk: false,
@@ -1061,6 +1134,7 @@ var Money = class {
1061
1134
  this.precision = 10;
1062
1135
  this.scale = 2;
1063
1136
  this.requerido = false;
1137
+ this.comentario = "";
1064
1138
  this.precision = presicion;
1065
1139
  this.scale = decimales;
1066
1140
  }
@@ -1072,6 +1146,10 @@ var Money = class {
1072
1146
  this.defaultData = value;
1073
1147
  return this;
1074
1148
  }
1149
+ comment(comentario) {
1150
+ this.comentario = comentario;
1151
+ return this;
1152
+ }
1075
1153
  $() {
1076
1154
  const parts = [];
1077
1155
  const db = getTipoConexion();
@@ -1082,6 +1160,9 @@ var Money = class {
1082
1160
  if (this.defaultData !== void 0) {
1083
1161
  parts.push(`DEFAULT ${this.defaultData.toFixed(this.scale)}`);
1084
1162
  }
1163
+ if (db === "mysql" && this.comentario.length > 2) {
1164
+ parts.push(` COMMENT '${this.comentario}' `);
1165
+ }
1085
1166
  const response = {
1086
1167
  typo: "money",
1087
1168
  pk: false,
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
10
10
  var Validator = class {
11
11
  };
12
12
  Validator.isValidTable = (val) => /^(?![0-9_])[a-z][a-z0-9_]{0,62}$/.test(val);
13
- Validator.isValidColumn = (val) => /^[a-z][a-z0-9_]{0,62}$/.test(val);
13
+ Validator.isValidColumn = (val) => /^[a-zA-Z][a-zA-Z0-9]{0,62}$/.test(val);
14
14
  Validator.isValidUsername = (val) => /^[a-zA-Z0-9\-_]+$/.test(val);
15
15
  var RESERVED_WORDS = /* @__PURE__ */ new Set([
16
16
  "select",
@@ -154,7 +154,7 @@ function defineTable(tableName, columns) {
154
154
  const fn = () => tableName;
155
155
  if (!Validator.isValidTable(tableName)) {
156
156
  throw new Error(
157
- "El nombre de la tabla no puede contener mayusculas o caracteres especiales"
157
+ "El nombre de la tabla no puede contener mayusculas o caracteres especiales : " + tableName
158
158
  );
159
159
  }
160
160
  if (RESERVED_WORDS.has(tableName)) {
@@ -181,7 +181,7 @@ function defineTable(tableName, columns) {
181
181
  if (prop === "toString") return () => tableName;
182
182
  if (prop === "valueOf") return () => tableName;
183
183
  if (prop in columns) {
184
- return `${tableName}.${prop.toString()}`;
184
+ return tipoConexionZORMZ3691 === "mysql" ? `${tableName}.\`${prop.toString()}\` ` : `${tableName}."${prop.toString()}" `;
185
185
  }
186
186
  return void 0;
187
187
  },
@@ -203,14 +203,15 @@ function defineTable(tableName, columns) {
203
203
  });
204
204
  return proxy;
205
205
  }
206
- async function generateTable(tabla, columns) {
206
+ async function generateTable(tabla, columns, seeSQL = false) {
207
207
  let queries = "";
208
208
  let columnDefs = [];
209
+ let cheksOut = [];
209
210
  let sql = "";
210
211
  let id = false;
211
212
  for (const columnName in columns) {
212
213
  const col = columns[columnName];
213
- sql = ` ${columnName} `;
214
+ sql = tipoConexionZORMZ3691 === "mysql" ? `\`${columnName}\` ` : `"${columnName}" `;
214
215
  if (!col.typo) {
215
216
  throw new Error(`La columna ${columnName} no tiene el tipo definido`);
216
217
  }
@@ -224,16 +225,28 @@ async function generateTable(tabla, columns) {
224
225
  id = col.pk === true ? true : false;
225
226
  sql += col.sqlz;
226
227
  columnDefs.push(sql);
228
+ if (col.check !== void 0) {
229
+ cheksOut.push(
230
+ `CONSTRAINT chk_${columnName} CHECK (${columnName} IN ( ${col.check}))`
231
+ );
232
+ }
227
233
  }
228
234
  queries += `CREATE TABLE IF NOT EXISTS ${tabla} (
229
235
  `;
230
236
  queries += columnDefs.join(", \n");
237
+ if (cheksOut.length > 0) {
238
+ queries += ",\n";
239
+ }
240
+ queries += cheksOut.join(",\n");
231
241
  queries += ");";
232
242
  if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
233
243
  throw new Error(
234
244
  "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
235
245
  );
236
246
  }
247
+ if (seeSQL) {
248
+ console.log(queries);
249
+ }
237
250
  if (tipoConexionZORMZ3691 === "mysql") {
238
251
  const response = await conexionZORMZ3691.executeConsulta({
239
252
  query: queries,
@@ -354,7 +367,6 @@ var QueryBuilder = class {
354
367
  this.tabla = tabla;
355
368
  this.parametros = parametros;
356
369
  this.valores = [];
357
- this.valorRetorno = null;
358
370
  this.conexion = conexion;
359
371
  }
360
372
  /**
@@ -375,8 +387,11 @@ var QueryBuilder = class {
375
387
  this.valores = values;
376
388
  return this;
377
389
  }
390
+ Returning(idRetorno) {
391
+ this.returning = idRetorno;
392
+ return this;
393
+ }
378
394
  async execute(see = false) {
379
- this.valorRetorno = 1;
380
395
  let query1 = `INSERT INTO ${this.tabla} `;
381
396
  let param = "";
382
397
  let arrayArrays = false;
@@ -438,15 +453,26 @@ var QueryBuilder = class {
438
453
  valores: arrayArrays ? [this.valores] : this.valores,
439
454
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
440
455
  });
441
- return respuesta.insertId;
456
+ let response = [];
457
+ if (this.returning !== void 0) {
458
+ for (let i = 0; i < this.valores.length; i++) {
459
+ response.push(respuesta.insertId + i);
460
+ }
461
+ }
462
+ return response;
442
463
  } else if (this.conexion.tipo === "pg") {
443
- query += " RETURNING id ";
464
+ if (this.returning !== void 0)
465
+ query += ` RETURNING ${this.returning} `;
444
466
  const respuesta = await this.conexion.executeConsulta({
445
467
  query,
446
468
  valores: this.valores,
447
469
  mensaje: `Ocurrio un error al ingresar datos a ${this.tabla} `
448
470
  });
449
- return respuesta.rows;
471
+ let response = [];
472
+ if (respuesta.rows !== void 0) {
473
+ response = respuesta.rows.map((obj) => Object.values(obj)[0]);
474
+ }
475
+ return response;
450
476
  }
451
477
  }
452
478
  };
@@ -692,7 +718,7 @@ var Update = class {
692
718
  }
693
719
  } else if (validate) {
694
720
  valores.forEach((valors) => {
695
- valor += eq(valors.campoUp, valors.newCampoUp, !valors.dataTable);
721
+ valor += eq(valors.campoUp.replace(`${this.nombreTabla}.`, ""), valors.newCampoUp.replace(`${this.nombreTabla}.`, ""), !valors.dataTable);
696
722
  valor += ",";
697
723
  });
698
724
  }
@@ -723,7 +749,7 @@ var Update = class {
723
749
  async execute(seeQuery = false) {
724
750
  const query = `UPDATE ${this.nombreTabla} SET ${this.valores} ${this.condicion};`;
725
751
  if (seeQuery) {
726
- console.log(seeQuery);
752
+ console.log(query);
727
753
  }
728
754
  const respuesta = await this.conexion.executeConsulta({
729
755
  query,
@@ -732,9 +758,7 @@ var Update = class {
732
758
  if (this.conexion.tipo === "mysql") {
733
759
  return respuesta.affectedRows;
734
760
  } else {
735
- return {
736
- resultado: respuesta.rowCount
737
- };
761
+ return respuesta.rowCount;
738
762
  }
739
763
  }
740
764
  };
@@ -784,6 +808,7 @@ var IntColumn = class {
784
808
  this.unique = false;
785
809
  this.autoIncrement = false;
786
810
  this.unsingned = { uso: false, valor: 0 };
811
+ this.comentario = "";
787
812
  }
788
813
  Required() {
789
814
  this.requerido = true;
@@ -794,6 +819,10 @@ var IntColumn = class {
794
819
  this.pk = true;
795
820
  return this;
796
821
  }
822
+ Comment(comentario) {
823
+ this.comentario = comentario;
824
+ return this;
825
+ }
797
826
  Unique() {
798
827
  this.unique = true;
799
828
  return this;
@@ -852,6 +881,9 @@ var IntColumn = class {
852
881
  parts.push(`DEFAULT ${this.defaultData}`);
853
882
  }
854
883
  if (this.unique) parts.push("UNIQUE");
884
+ if (db === "mysql" && this.comentario.length > 2) {
885
+ parts.push(` COMMENT '${this.comentario}' `);
886
+ }
855
887
  const valor = {
856
888
  pk: false,
857
889
  typo: "int",
@@ -871,6 +903,9 @@ var Varchar = class {
871
903
  this.defaultData = "";
872
904
  this.requerido = false;
873
905
  this.unique = false;
906
+ this.enum = "";
907
+ this.campo = "";
908
+ this.comentarios = "";
874
909
  this.maxLenth = cantidad;
875
910
  }
876
911
  withType({
@@ -884,10 +919,27 @@ var Varchar = class {
884
919
  this.unique = unique;
885
920
  return this.Default(defaultData).$();
886
921
  }
922
+ /**
923
+ *
924
+ * @param {string} campo
925
+ * @param {string[]} datos
926
+ * @example
927
+ * Check("example", ["operativo","denegado","revisando"])
928
+ *
929
+ * @returns
930
+ */
931
+ Check(datos) {
932
+ this.enum = datos.map((caracter) => `'${caracter}'`).join(",");
933
+ return this;
934
+ }
887
935
  Required() {
888
936
  this.requerido = true;
889
937
  return this;
890
938
  }
939
+ Comment(comentario) {
940
+ this.comentarios = comentario;
941
+ return this;
942
+ }
891
943
  Unique() {
892
944
  this.unique = true;
893
945
  return this;
@@ -902,11 +954,16 @@ var Varchar = class {
902
954
  return this;
903
955
  }
904
956
  $() {
905
- let sqlz = `VARCHAR(${this.maxLenth}) ${this.requerido ? "NOT NULL" : "NULL"} ${this.defaultData.length > 0 ? ` DEFAULT ${this.defaultData} ` : " "} ${this.unique ? " UNIQUE" : " "} `;
957
+ let sqlz = `VARCHAR(${this.maxLenth}) ${this.requerido ? "NOT NULL" : "NULL"} ${this.defaultData.length > 0 ? ` DEFAULT ${this.defaultData} ` : " "} ${this.unique ? " UNIQUE" : " "}`;
958
+ const db = getTipoConexion();
959
+ if (db === "mysql" && this.comentarios.length > 2) {
960
+ sqlz += ` COMMENT '${this.comentarios}' `;
961
+ }
906
962
  const response = {
907
963
  typo: "varchar",
908
964
  pk: false,
909
- sqlz
965
+ sqlz,
966
+ check: this.enum.length > 2 ? this.enum : void 0
910
967
  };
911
968
  return response;
912
969
  }
@@ -919,11 +976,16 @@ function varchar(cantidad = 100) {
919
976
  var BoolColumn = class {
920
977
  constructor() {
921
978
  this.requerido = false;
979
+ this.comentario = "";
922
980
  }
923
981
  required() {
924
982
  this.requerido = true;
925
983
  return this;
926
984
  }
985
+ Comment(comentario) {
986
+ this.comentario = comentario;
987
+ return this;
988
+ }
927
989
  default(value) {
928
990
  this.defaultData = value;
929
991
  return this;
@@ -938,6 +1000,9 @@ var BoolColumn = class {
938
1000
  `DEFAULT ${db === "mysql" ? this.defaultData ? 1 : 0 : this.defaultData}`
939
1001
  );
940
1002
  }
1003
+ if (db === "mysql" && this.comentario.length > 2) {
1004
+ parts.push(` COMMENT '${this.comentario}' `);
1005
+ }
941
1006
  const response = {
942
1007
  typo: "bool",
943
1008
  pk: false,
@@ -956,11 +1021,16 @@ var Timestamp = class {
956
1021
  this.requerido = false;
957
1022
  this.defaultNow = false;
958
1023
  this.onUpdateNow = false;
1024
+ this.comentario = "";
959
1025
  }
960
1026
  required() {
961
1027
  this.requerido = true;
962
1028
  return this;
963
1029
  }
1030
+ comment(comentario) {
1031
+ this.comentario = comentario;
1032
+ return this;
1033
+ }
964
1034
  now() {
965
1035
  this.defaultNow = true;
966
1036
  return this;
@@ -980,6 +1050,9 @@ var Timestamp = class {
980
1050
  if (this.onUpdateNow && db === "mysql") {
981
1051
  parts.push("ON UPDATE CURRENT_TIMESTAMP");
982
1052
  }
1053
+ if (db === "mysql" && this.comentario.length > 2) {
1054
+ parts.push(` COMMENT '${this.comentario}' `);
1055
+ }
983
1056
  const response = {
984
1057
  typo: "timestamp",
985
1058
  pk: false,
@@ -998,6 +1071,7 @@ var Money = class {
998
1071
  this.precision = 10;
999
1072
  this.scale = 2;
1000
1073
  this.requerido = false;
1074
+ this.comentario = "";
1001
1075
  this.precision = presicion;
1002
1076
  this.scale = decimales;
1003
1077
  }
@@ -1009,6 +1083,10 @@ var Money = class {
1009
1083
  this.defaultData = value;
1010
1084
  return this;
1011
1085
  }
1086
+ comment(comentario) {
1087
+ this.comentario = comentario;
1088
+ return this;
1089
+ }
1012
1090
  $() {
1013
1091
  const parts = [];
1014
1092
  const db = getTipoConexion();
@@ -1019,6 +1097,9 @@ var Money = class {
1019
1097
  if (this.defaultData !== void 0) {
1020
1098
  parts.push(`DEFAULT ${this.defaultData.toFixed(this.scale)}`);
1021
1099
  }
1100
+ if (db === "mysql" && this.comentario.length > 2) {
1101
+ parts.push(` COMMENT '${this.comentario}' `);
1102
+ }
1022
1103
  const response = {
1023
1104
  typo: "money",
1024
1105
  pk: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Un ORM que busca ser ligero y facil de usar",
5
5
  "author": "yukio-kayaba",
6
6
  "license": "ISC",