zormz 1.2.8 → 1.3.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 CHANGED
@@ -93,7 +93,9 @@ export const prueba1 = defineTable("prueba1", {
93
93
  * **.pk()** define la columna como clave primaria
94
94
  * **.Default()** entrega un valor por defecto
95
95
  * **.$()** finaliza la definicion y entrega un valor compatible con *$columns*
96
-
96
+ * **.required()** Indica que los valores de la fila no podran ser null, si o si un valor obligatorio
97
+ * **.now()** Solo esta disponible para timestamp , indica fecha automatica de registra
98
+ * **.onUpdate()** Tomara la fecha actual cada ves que se haga un update
97
99
  ## Generacion de tablas
98
100
  ```ts
99
101
  generateTable(prueba1(), prueba1.$columns);
@@ -102,6 +104,11 @@ Esto crea la tabla en la base de datos respetando tipos, claves primarias y valo
102
104
 
103
105
  ---
104
106
 
107
+ ## Eliminar tablas
108
+ ```ts
109
+ await dropTable(prueba4());
110
+ ```
111
+
105
112
  ## Insertar Datos
106
113
 
107
114
  ```ts
@@ -156,6 +163,8 @@ const conexion: connecionLocal = {
156
163
  };
157
164
 
158
165
  getConexion("pg", conexion);
166
+ //MYSQL
167
+ //getConexion("mysql", conexion);
159
168
 
160
169
  const prueba1 = defineTable("prueba1", {
161
170
  id: int().Pk().$(),
@@ -193,7 +202,8 @@ pruebaData().catch(console.error);
193
202
  * ORM en version inicial con enfoque de tipado y autompletado
194
203
  * Compatible con **MYSQL** y **PG**
195
204
  * Preparado para extenderse
196
-
205
+ * Las versiones +1.3.0 son mas estables , las anteriores estaban en desarrollo y presentan multiples errores
206
+ * verion mas estable 1.3.1
197
207
  ## Licencia
198
208
 
199
209
  ISC © Yukio-kayaba
package/dist/index.d.mts CHANGED
@@ -41,21 +41,22 @@ interface Consultas {
41
41
  query: string;
42
42
  valores?: any[] | [[]];
43
43
  mensaje?: string;
44
+ alertar?: boolean;
44
45
  }
45
46
  interface connecionRed {
46
47
  connectionString: string;
47
48
  }
48
49
  type connectionDB = "mysql" | "pg";
49
- declare function getTipoConexion(): connectionDB;
50
50
  declare class BDconnection {
51
51
  tipo: connectionDB;
52
52
  pool: any;
53
53
  private connection;
54
54
  constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
55
- private connecionMyql;
55
+ private conexionMysql;
56
56
  private connectionPG;
57
- executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
57
+ executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<any>;
58
58
  }
59
+ declare function getTipoConexion(): connectionDB;
59
60
  /**
60
61
  *
61
62
  * @param bd
@@ -94,6 +95,7 @@ type TableProxy<TCols> = {
94
95
  */
95
96
  declare function defineTable<T extends Record<string, ColumnDefinition>>(tableName: string, columns: T): TableProxy<T>;
96
97
  declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T): Promise<void>;
98
+ declare function dropTable(nombreTabla: string): Promise<void>;
97
99
 
98
100
  declare class DeleteR {
99
101
  #private;
@@ -428,4 +430,4 @@ declare class Money {
428
430
  }
429
431
  declare function money(presicion?: number, decimales?: number): Money;
430
432
 
431
- 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 };
433
+ 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, dropTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, timestamp, type valor, varchar };
package/dist/index.d.ts CHANGED
@@ -41,21 +41,22 @@ interface Consultas {
41
41
  query: string;
42
42
  valores?: any[] | [[]];
43
43
  mensaje?: string;
44
+ alertar?: boolean;
44
45
  }
45
46
  interface connecionRed {
46
47
  connectionString: string;
47
48
  }
48
49
  type connectionDB = "mysql" | "pg";
49
- declare function getTipoConexion(): connectionDB;
50
50
  declare class BDconnection {
51
51
  tipo: connectionDB;
52
52
  pool: any;
53
53
  private connection;
54
54
  constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
55
- private connecionMyql;
55
+ private conexionMysql;
56
56
  private connectionPG;
57
- executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
57
+ executeConsulta({ query, valores, mensaje, alertar, }: Consultas): Promise<any>;
58
58
  }
59
+ declare function getTipoConexion(): connectionDB;
59
60
  /**
60
61
  *
61
62
  * @param bd
@@ -94,6 +95,7 @@ type TableProxy<TCols> = {
94
95
  */
95
96
  declare function defineTable<T extends Record<string, ColumnDefinition>>(tableName: string, columns: T): TableProxy<T>;
96
97
  declare function generateTable<T extends Record<string, ColumnDefinition>>(tabla: string, columns: T): Promise<void>;
98
+ declare function dropTable(nombreTabla: string): Promise<void>;
97
99
 
98
100
  declare class DeleteR {
99
101
  #private;
@@ -428,4 +430,4 @@ declare class Money {
428
430
  }
429
431
  declare function money(presicion?: number, decimales?: number): Money;
430
432
 
431
- 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 };
433
+ 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, dropTable, eq, generateTable, getConexion, getRed, getTipoConexion, int, money, timestamp, type valor, varchar };
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ __export(index_exports, {
55
55
  Update: () => Update,
56
56
  bool: () => bool,
57
57
  defineTable: () => defineTable,
58
+ dropTable: () => dropTable,
58
59
  eq: () => eq,
59
60
  generateTable: () => generateTable,
60
61
  getConexion: () => getConexion,
@@ -67,19 +68,30 @@ __export(index_exports, {
67
68
  });
68
69
  module.exports = __toCommonJS(index_exports);
69
70
 
71
+ // conection/validator.ts
72
+ var Validator = class {
73
+ };
74
+ Validator.isValidTable = (val) => /^(?![0-9_])[a-z][a-z0-9_]{0,62}$/.test(val);
75
+ Validator.isValidColumn = (val) => /^[a-z][a-z0-9_]{0,62}$/.test(val);
76
+ Validator.isValidUsername = (val) => /^[a-zA-Z0-9\-_]+$/.test(val);
77
+ var RESERVED_WORDS = /* @__PURE__ */ new Set([
78
+ "select",
79
+ "table",
80
+ "user",
81
+ "order",
82
+ "group",
83
+ "where",
84
+ "join"
85
+ ]);
86
+
70
87
  // conection/db.ts
71
- var conexionZORMZ3691;
72
- var tipoConexionZORMZ3691;
73
- function getTipoConexion() {
74
- return tipoConexionZORMZ3691;
75
- }
76
88
  var BDconnection = class {
77
89
  constructor(bd, datos) {
78
90
  this.tipo = "pg";
79
91
  this.tipo = bd;
80
92
  this.connection = datos;
81
93
  }
82
- async connecionMyql() {
94
+ async conexionMysql() {
83
95
  try {
84
96
  const mysql = await import("mysql2/promise");
85
97
  if ("connectionString" in this.connection)
@@ -93,7 +105,9 @@ var BDconnection = class {
93
105
  });
94
106
  return pool;
95
107
  } catch (error) {
96
- throw new Error("Mysql no esta instalado . para instalarlo corre : npm install mysql2 ");
108
+ throw new Error(
109
+ "Mysql no esta instalado . para instalarlo corre : npm install mysql2 "
110
+ );
97
111
  }
98
112
  }
99
113
  async connectionPG() {
@@ -119,16 +133,20 @@ var BDconnection = class {
119
133
  console.error(
120
134
  "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
121
135
  );
136
+ throw new Error(
137
+ "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
138
+ );
122
139
  }
123
140
  }
124
141
  async executeConsulta({
125
142
  query,
126
143
  valores = void 0,
127
- mensaje
144
+ mensaje,
145
+ alertar = true
128
146
  }) {
129
147
  try {
130
148
  if (this.tipo === "mysql") {
131
- const pool = await this.connecionMyql();
149
+ const pool = await this.conexionMysql();
132
150
  const [rows] = await pool.query(query, valores);
133
151
  return rows;
134
152
  } else if (this.tipo === "pg") {
@@ -146,6 +164,9 @@ var BDconnection = class {
146
164
  }
147
165
  }
148
166
  const pool2 = await this.connectionPG();
167
+ if (!pool2) {
168
+ throw new Error("No se pudo establecer la conexi\xF3n con PostgreSQL");
169
+ }
149
170
  const respuesta = await pool2.query(query2, valores);
150
171
  if (!respuesta) {
151
172
  throw new Error(` Este usuario no esta registrado `);
@@ -154,6 +175,7 @@ var BDconnection = class {
154
175
  }
155
176
  } catch (error) {
156
177
  console.log(error);
178
+ if (!alertar) return;
157
179
  if (typeof error === "object" && error !== null && "code" in error) {
158
180
  if (error.code === "ETIMEDOUT") {
159
181
  throw new Error(`Su red esta limitando el acceso`);
@@ -163,20 +185,56 @@ var BDconnection = class {
163
185
  }
164
186
  }
165
187
  };
188
+ var conexionZORMZ3691;
189
+ var tipoConexionZORMZ3691;
190
+ function getTipoConexion() {
191
+ if (!tipoConexionZORMZ3691) {
192
+ throw new Error(
193
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
194
+ );
195
+ }
196
+ return tipoConexionZORMZ3691;
197
+ }
166
198
  async function getConexion(bd, datos) {
167
199
  conexionZORMZ3691 = new BDconnection(bd, datos);
168
200
  tipoConexionZORMZ3691 = conexionZORMZ3691.tipo;
169
- await conexionZORMZ3691.executeConsulta({ "query": "select 1+1;" }).then((data) => {
201
+ await conexionZORMZ3691.executeConsulta({ query: "select 1+1;" }).then((data) => {
170
202
  console.log(`\u{1F44D}\u{1F44D} Conexi\xF3n ${tipoConexionZORMZ3691} exitosa \u{1F61C}`);
171
203
  }).catch((err) => {
172
204
  console.error(" \u{1F622}\u{1F622} Error al conectar a " + tipoConexionZORMZ3691);
205
+ console.log(err);
173
206
  });
174
207
  }
175
208
  function getRed() {
209
+ if (!conexionZORMZ3691) {
210
+ throw new Error(
211
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
212
+ );
213
+ }
176
214
  return conexionZORMZ3691;
177
215
  }
178
216
  function defineTable(tableName, columns) {
179
217
  const fn = () => tableName;
218
+ if (!Validator.isValidTable(tableName)) {
219
+ throw new Error(
220
+ "El nombre de la tabla no puede contener mayusculas o caracteres especiales"
221
+ );
222
+ }
223
+ if (RESERVED_WORDS.has(tableName)) {
224
+ throw new Error(`el nombre ${tableName} es una palabra reservada SQL`);
225
+ }
226
+ for (const campo in columns) {
227
+ if (!Validator.isValidColumn(campo)) {
228
+ throw new Error(
229
+ `El campo ${campo} no puede contener caracteres especiales`
230
+ );
231
+ }
232
+ if (RESERVED_WORDS.has(campo)) {
233
+ throw new Error(
234
+ `El campo ${campo} contiene palabras reservadas de sql \u274C\u274C\u274C `
235
+ );
236
+ }
237
+ }
180
238
  const proxy = new Proxy(fn, {
181
239
  get(_target, prop) {
182
240
  if (prop === "$columns") {
@@ -234,8 +292,16 @@ async function generateTable(tabla, columns) {
234
292
  `;
235
293
  queries += columnDefs.join(", \n");
236
294
  queries += ");";
295
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
296
+ throw new Error(
297
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
298
+ );
299
+ }
237
300
  if (tipoConexionZORMZ3691 === "mysql") {
238
- const response = await conexionZORMZ3691.executeConsulta({ query: queries, mensaje: "Error al crear la base de datos" });
301
+ const response = await conexionZORMZ3691.executeConsulta({
302
+ query: queries,
303
+ mensaje: "Error al crear la tabla"
304
+ });
239
305
  if (response.warningStatus > 0) {
240
306
  console.log(` La tabla ${tabla} ya existe \u{1F642}\u{1F610} `);
241
307
  } else {
@@ -250,6 +316,33 @@ async function generateTable(tabla, columns) {
250
316
  console.log(`\u{1F44D}\u{1F44D} Se creo con exito la tabla ${tabla} \u{1F61C}`);
251
317
  }
252
318
  }
319
+ async function dropTable(nombreTabla) {
320
+ let sql = `DROP TABLE IF EXISTS ${nombreTabla};`;
321
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
322
+ throw new Error(
323
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
324
+ );
325
+ }
326
+ if (tipoConexionZORMZ3691 === "mysql") {
327
+ const response = await conexionZORMZ3691.executeConsulta({
328
+ query: sql,
329
+ mensaje: "Error al eliminar la tabla",
330
+ alertar: false
331
+ });
332
+ if (response.warningStatus === 0) {
333
+ console.log(`\u{1F44D}\u{1F44D} Se creo con exito la tabla ${nombreTabla} \u{1F44D}`);
334
+ return;
335
+ }
336
+ console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
337
+ } else if (tipoConexionZORMZ3691 === "pg") {
338
+ const response = await conexionZORMZ3691.executeConsulta({
339
+ query: sql,
340
+ mensaje: "Error al eliminar la tabla",
341
+ alertar: false
342
+ });
343
+ console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
344
+ }
345
+ }
253
346
 
254
347
  // conection/middleware/delete.ts
255
348
  var _condicion, _tabla;
@@ -286,13 +379,15 @@ var DeleteR = class {
286
379
  if (this.conexion.tipo === "mysql") {
287
380
  const respuesta = await this.conexion.executeConsulta({
288
381
  query,
289
- mensaje: "Ocurrio un error al momento de eliminar un dato"
382
+ mensaje: "Ocurrio un error al momento de eliminar",
383
+ alertar: false
290
384
  });
291
385
  return respuesta.affectedRows;
292
386
  } else {
293
387
  const respuesta = await this.conexion.executeConsulta({
294
388
  query,
295
- mensaje: "Ocurrio un error al momento de eliminar un dato"
389
+ mensaje: "Ocurrio un error al momento de eliminar",
390
+ alertar: false
296
391
  });
297
392
  return respuesta.rowCount;
298
393
  }
@@ -990,6 +1085,7 @@ function money(presicion = 10, decimales = 2) {
990
1085
  Update,
991
1086
  bool,
992
1087
  defineTable,
1088
+ dropTable,
993
1089
  eq,
994
1090
  generateTable,
995
1091
  getConexion,
package/dist/index.mjs CHANGED
@@ -6,19 +6,30 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
8
 
9
+ // conection/validator.ts
10
+ var Validator = class {
11
+ };
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);
14
+ Validator.isValidUsername = (val) => /^[a-zA-Z0-9\-_]+$/.test(val);
15
+ var RESERVED_WORDS = /* @__PURE__ */ new Set([
16
+ "select",
17
+ "table",
18
+ "user",
19
+ "order",
20
+ "group",
21
+ "where",
22
+ "join"
23
+ ]);
24
+
9
25
  // conection/db.ts
10
- var conexionZORMZ3691;
11
- var tipoConexionZORMZ3691;
12
- function getTipoConexion() {
13
- return tipoConexionZORMZ3691;
14
- }
15
26
  var BDconnection = class {
16
27
  constructor(bd, datos) {
17
28
  this.tipo = "pg";
18
29
  this.tipo = bd;
19
30
  this.connection = datos;
20
31
  }
21
- async connecionMyql() {
32
+ async conexionMysql() {
22
33
  try {
23
34
  const mysql = await import("mysql2/promise");
24
35
  if ("connectionString" in this.connection)
@@ -32,7 +43,9 @@ var BDconnection = class {
32
43
  });
33
44
  return pool;
34
45
  } catch (error) {
35
- throw new Error("Mysql no esta instalado . para instalarlo corre : npm install mysql2 ");
46
+ throw new Error(
47
+ "Mysql no esta instalado . para instalarlo corre : npm install mysql2 "
48
+ );
36
49
  }
37
50
  }
38
51
  async connectionPG() {
@@ -58,16 +71,20 @@ var BDconnection = class {
58
71
  console.error(
59
72
  "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
60
73
  );
74
+ throw new Error(
75
+ "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
76
+ );
61
77
  }
62
78
  }
63
79
  async executeConsulta({
64
80
  query,
65
81
  valores = void 0,
66
- mensaje
82
+ mensaje,
83
+ alertar = true
67
84
  }) {
68
85
  try {
69
86
  if (this.tipo === "mysql") {
70
- const pool = await this.connecionMyql();
87
+ const pool = await this.conexionMysql();
71
88
  const [rows] = await pool.query(query, valores);
72
89
  return rows;
73
90
  } else if (this.tipo === "pg") {
@@ -85,6 +102,9 @@ var BDconnection = class {
85
102
  }
86
103
  }
87
104
  const pool2 = await this.connectionPG();
105
+ if (!pool2) {
106
+ throw new Error("No se pudo establecer la conexi\xF3n con PostgreSQL");
107
+ }
88
108
  const respuesta = await pool2.query(query2, valores);
89
109
  if (!respuesta) {
90
110
  throw new Error(` Este usuario no esta registrado `);
@@ -93,6 +113,7 @@ var BDconnection = class {
93
113
  }
94
114
  } catch (error) {
95
115
  console.log(error);
116
+ if (!alertar) return;
96
117
  if (typeof error === "object" && error !== null && "code" in error) {
97
118
  if (error.code === "ETIMEDOUT") {
98
119
  throw new Error(`Su red esta limitando el acceso`);
@@ -102,20 +123,56 @@ var BDconnection = class {
102
123
  }
103
124
  }
104
125
  };
126
+ var conexionZORMZ3691;
127
+ var tipoConexionZORMZ3691;
128
+ function getTipoConexion() {
129
+ if (!tipoConexionZORMZ3691) {
130
+ throw new Error(
131
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
132
+ );
133
+ }
134
+ return tipoConexionZORMZ3691;
135
+ }
105
136
  async function getConexion(bd, datos) {
106
137
  conexionZORMZ3691 = new BDconnection(bd, datos);
107
138
  tipoConexionZORMZ3691 = conexionZORMZ3691.tipo;
108
- await conexionZORMZ3691.executeConsulta({ "query": "select 1+1;" }).then((data) => {
139
+ await conexionZORMZ3691.executeConsulta({ query: "select 1+1;" }).then((data) => {
109
140
  console.log(`\u{1F44D}\u{1F44D} Conexi\xF3n ${tipoConexionZORMZ3691} exitosa \u{1F61C}`);
110
141
  }).catch((err) => {
111
142
  console.error(" \u{1F622}\u{1F622} Error al conectar a " + tipoConexionZORMZ3691);
143
+ console.log(err);
112
144
  });
113
145
  }
114
146
  function getRed() {
147
+ if (!conexionZORMZ3691) {
148
+ throw new Error(
149
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
150
+ );
151
+ }
115
152
  return conexionZORMZ3691;
116
153
  }
117
154
  function defineTable(tableName, columns) {
118
155
  const fn = () => tableName;
156
+ if (!Validator.isValidTable(tableName)) {
157
+ throw new Error(
158
+ "El nombre de la tabla no puede contener mayusculas o caracteres especiales"
159
+ );
160
+ }
161
+ if (RESERVED_WORDS.has(tableName)) {
162
+ throw new Error(`el nombre ${tableName} es una palabra reservada SQL`);
163
+ }
164
+ for (const campo in columns) {
165
+ if (!Validator.isValidColumn(campo)) {
166
+ throw new Error(
167
+ `El campo ${campo} no puede contener caracteres especiales`
168
+ );
169
+ }
170
+ if (RESERVED_WORDS.has(campo)) {
171
+ throw new Error(
172
+ `El campo ${campo} contiene palabras reservadas de sql \u274C\u274C\u274C `
173
+ );
174
+ }
175
+ }
119
176
  const proxy = new Proxy(fn, {
120
177
  get(_target, prop) {
121
178
  if (prop === "$columns") {
@@ -173,8 +230,16 @@ async function generateTable(tabla, columns) {
173
230
  `;
174
231
  queries += columnDefs.join(", \n");
175
232
  queries += ");";
233
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
234
+ throw new Error(
235
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
236
+ );
237
+ }
176
238
  if (tipoConexionZORMZ3691 === "mysql") {
177
- const response = await conexionZORMZ3691.executeConsulta({ query: queries, mensaje: "Error al crear la base de datos" });
239
+ const response = await conexionZORMZ3691.executeConsulta({
240
+ query: queries,
241
+ mensaje: "Error al crear la tabla"
242
+ });
178
243
  if (response.warningStatus > 0) {
179
244
  console.log(` La tabla ${tabla} ya existe \u{1F642}\u{1F610} `);
180
245
  } else {
@@ -189,6 +254,33 @@ async function generateTable(tabla, columns) {
189
254
  console.log(`\u{1F44D}\u{1F44D} Se creo con exito la tabla ${tabla} \u{1F61C}`);
190
255
  }
191
256
  }
257
+ async function dropTable(nombreTabla) {
258
+ let sql = `DROP TABLE IF EXISTS ${nombreTabla};`;
259
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
260
+ throw new Error(
261
+ "La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero."
262
+ );
263
+ }
264
+ if (tipoConexionZORMZ3691 === "mysql") {
265
+ const response = await conexionZORMZ3691.executeConsulta({
266
+ query: sql,
267
+ mensaje: "Error al eliminar la tabla",
268
+ alertar: false
269
+ });
270
+ if (response.warningStatus === 0) {
271
+ console.log(`\u{1F44D}\u{1F44D} Se creo con exito la tabla ${nombreTabla} \u{1F44D}`);
272
+ return;
273
+ }
274
+ console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
275
+ } else if (tipoConexionZORMZ3691 === "pg") {
276
+ const response = await conexionZORMZ3691.executeConsulta({
277
+ query: sql,
278
+ mensaje: "Error al eliminar la tabla",
279
+ alertar: false
280
+ });
281
+ console.log(` No existe la tabla ${nombreTabla} \u{1F622}`);
282
+ }
283
+ }
192
284
 
193
285
  // conection/middleware/delete.ts
194
286
  var _condicion, _tabla;
@@ -225,13 +317,15 @@ var DeleteR = class {
225
317
  if (this.conexion.tipo === "mysql") {
226
318
  const respuesta = await this.conexion.executeConsulta({
227
319
  query,
228
- mensaje: "Ocurrio un error al momento de eliminar un dato"
320
+ mensaje: "Ocurrio un error al momento de eliminar",
321
+ alertar: false
229
322
  });
230
323
  return respuesta.affectedRows;
231
324
  } else {
232
325
  const respuesta = await this.conexion.executeConsulta({
233
326
  query,
234
- mensaje: "Ocurrio un error al momento de eliminar un dato"
327
+ mensaje: "Ocurrio un error al momento de eliminar",
328
+ alertar: false
235
329
  });
236
330
  return respuesta.rowCount;
237
331
  }
@@ -928,6 +1022,7 @@ export {
928
1022
  Update,
929
1023
  bool,
930
1024
  defineTable,
1025
+ dropTable,
931
1026
  eq,
932
1027
  generateTable,
933
1028
  getConexion,
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.2.8",
4
- "description": "",
5
- "author": "",
3
+ "version": "1.3.1",
4
+ "description": "Un ORM que busca ser ligero y facil de usar",
5
+ "author": "yukio-kayaba",
6
6
  "license": "ISC",
7
+ "keywords": [
8
+ "orm",
9
+ "database",
10
+ "postgresql",
11
+ "mysql",
12
+ "sql",
13
+ "typescript",
14
+ "zomrz",
15
+ "pg"
16
+ ],
7
17
  "main": "./dist/index.cjs",
8
18
  "module": "./dist/index.js",
9
19
  "types": "./dist/index.d.ts",
10
20
  "exports": {
11
21
  ".": {
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
22
+ "require": "./dist/index.js",
23
+ "import": "./dist/index.mjs"
14
24
  }
15
25
  },
16
26
  "files": [