@oino-ts/db-mariadb 1.1.0 → 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.
@@ -443,6 +443,24 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`;
443
443
  }
444
444
  return fields;
445
445
  }
446
+ /**
447
+ * Get the names of all user (base) tables in the database schema, excluding system tables and views.
448
+ *
449
+ */
450
+ async getSchemaTables() {
451
+ const tables = [];
452
+ const sql = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" + this.dbParams.database + "' AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;";
453
+ const tables_res = await this._query(sql);
454
+ while (!tables_res.isEof()) {
455
+ const row = tables_res.getRow();
456
+ const table_name = row[0]?.toString() || "";
457
+ if (table_name) {
458
+ tables.push(table_name);
459
+ }
460
+ await tables_res.next();
461
+ }
462
+ return tables;
463
+ }
446
464
  /**
447
465
  * Resolve the optimal native (SQL) type for a serialized field schema.
448
466
  *
@@ -440,6 +440,24 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`;
440
440
  }
441
441
  return fields;
442
442
  }
443
+ /**
444
+ * Get the names of all user (base) tables in the database schema, excluding system tables and views.
445
+ *
446
+ */
447
+ async getSchemaTables() {
448
+ const tables = [];
449
+ const sql = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" + this.dbParams.database + "' AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;";
450
+ const tables_res = await this._query(sql);
451
+ while (!tables_res.isEof()) {
452
+ const row = tables_res.getRow();
453
+ const table_name = row[0]?.toString() || "";
454
+ if (table_name) {
455
+ tables.push(table_name);
456
+ }
457
+ await tables_res.next();
458
+ }
459
+ return tables;
460
+ }
443
461
  /**
444
462
  * Resolve the optimal native (SQL) type for a serialized field schema.
445
463
  *
@@ -95,6 +95,11 @@ export declare class OINODbMariadb extends OINODb {
95
95
  *
96
96
  */
97
97
  getSchemaFields(tableName: string): Promise<OINODataField[]>;
98
+ /**
99
+ * Get the names of all user (base) tables in the database schema, excluding system tables and views.
100
+ *
101
+ */
102
+ getSchemaTables(): Promise<string[]>;
98
103
  /**
99
104
  * Resolve the optimal native (SQL) type for a serialized field schema.
100
105
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/db-mariadb",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "OINO TS package for using Mariadb databases.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -21,8 +21,8 @@
21
21
  "module": "./dist/esm/index.js",
22
22
  "types": "./dist/types/index.d.ts",
23
23
  "dependencies": {
24
- "@oino-ts/common": "^1.1.0",
25
- "@oino-ts/db": "^1.1.0",
24
+ "@oino-ts/common": "^1.1.1",
25
+ "@oino-ts/db": "^1.1.1",
26
26
  "mariadb": "^3.2.3"
27
27
  },
28
28
  "devDependencies": {
@@ -464,6 +464,25 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`
464
464
  return fields
465
465
  }
466
466
 
467
+ /**
468
+ * Get the names of all user (base) tables in the database schema, excluding system tables and views.
469
+ *
470
+ */
471
+ async getSchemaTables(): Promise<string[]> {
472
+ const tables:string[] = []
473
+ const sql:string = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" + this.dbParams.database + "' AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;"
474
+ const tables_res:OINODataSet = await this._query(sql)
475
+ while (!tables_res.isEof()) {
476
+ const row:OINODataRow = tables_res.getRow()
477
+ const table_name:string = row[0]?.toString() || ""
478
+ if (table_name) {
479
+ tables.push(table_name)
480
+ }
481
+ await tables_res.next()
482
+ }
483
+ return tables
484
+ }
485
+
467
486
  /**
468
487
  * Resolve the optimal native (SQL) type for a serialized field schema.
469
488
  *