mango-orm 1.0.0 → 1.0.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.
@@ -271,6 +271,7 @@ declare class Mango {
271
271
  getTables(): MangoTable<any>[];
272
272
  createTable<T>(name: string, fields: Record<string, MangoType>): Promise<MangoTable<T>>;
273
273
  dropTable(name: string): Promise<void>;
274
+ haveTable(name: string): boolean;
274
275
  customQuery<Type>(query: string, supplies: any[]): Promise<Type>;
275
276
  }
276
277
  export { Mango, MangoType, MangoTable };
package/dist/src/mango.js CHANGED
@@ -183,7 +183,7 @@ class MangoTable {
183
183
  if (Array.from(name.split(" ")).length > 1) {
184
184
  throw new Error("No spaces in table name allowed:");
185
185
  }
186
- this.tableName = name;
186
+ this.tableName = name.toLowerCase();
187
187
  this.tableFields = [...fields]; // Clone to prevent external mutations
188
188
  // Initialize query executor
189
189
  // this.query = new MangoQuery();
@@ -696,9 +696,10 @@ class Mango {
696
696
  return table;
697
697
  }
698
698
  async dropTable(name) {
699
+ // Find and remove from tables array first
699
700
  for (let i = 0; i < this.tables.length; i++) {
700
- if (this.tables[i].getName() === name) {
701
- this.query.query = "DROP TABLE " + name;
701
+ if (this.tables[i].getName() === name.toLowerCase()) {
702
+ this.query.query = "DROP TABLE " + name.toLowerCase();
702
703
  await this.query.execute();
703
704
  this.query.query = "";
704
705
  this.tables.splice(i, 1);
@@ -706,6 +707,14 @@ class Mango {
706
707
  }
707
708
  }
708
709
  }
710
+ haveTable(name) {
711
+ for (const table of this.tables) {
712
+ if (table.getName() === name.toLowerCase()) {
713
+ return true;
714
+ }
715
+ }
716
+ return false;
717
+ }
709
718
  customQuery(query, supplies) {
710
719
  return this.query.customQuery(query, supplies);
711
720
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-orm",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "A lightweight, type-safe MySQL ORM for Node.js and TypeScript",
6
6
  "main": "dist/src/mango.js",