@naturalcycles/mysql-lib 3.14.4 → 3.14.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/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { getDBAdapter } from './dbAdapter';
2
- import { MysqlDB, MysqlDBCfg, MysqlDBOptions, MysqlDBSaveOptions } from './mysql.db';
3
- import { MySQLKeyValueDB } from './mysqlKeyValueDB';
4
- import { jsonSchemaToMySQLDDL } from './schema/mysql.schema.util';
5
- export type { MysqlDBCfg, MysqlDBOptions, MysqlDBSaveOptions };
6
- export { MysqlDB, MySQLKeyValueDB, jsonSchemaToMySQLDDL, getDBAdapter };
1
+ export * from './mysql.db';
2
+ export * from './mysqlKeyValueDB';
3
+ export { jsonSchemaToMySQLDDL } from './schema/mysql.schema.util';
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDBAdapter = exports.jsonSchemaToMySQLDDL = exports.MySQLKeyValueDB = exports.MysqlDB = void 0;
4
- const dbAdapter_1 = require("./dbAdapter");
5
- Object.defineProperty(exports, "getDBAdapter", { enumerable: true, get: function () { return dbAdapter_1.getDBAdapter; } });
6
- const mysql_db_1 = require("./mysql.db");
7
- Object.defineProperty(exports, "MysqlDB", { enumerable: true, get: function () { return mysql_db_1.MysqlDB; } });
8
- const mysqlKeyValueDB_1 = require("./mysqlKeyValueDB");
9
- Object.defineProperty(exports, "MySQLKeyValueDB", { enumerable: true, get: function () { return mysqlKeyValueDB_1.MySQLKeyValueDB; } });
10
- const mysql_schema_util_1 = require("./schema/mysql.schema.util");
3
+ exports.jsonSchemaToMySQLDDL = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./mysql.db"), exports);
6
+ tslib_1.__exportStar(require("./mysqlKeyValueDB"), exports);
7
+ var mysql_schema_util_1 = require("./schema/mysql.schema.util");
11
8
  Object.defineProperty(exports, "jsonSchemaToMySQLDDL", { enumerable: true, get: function () { return mysql_schema_util_1.jsonSchemaToMySQLDDL; } });
@@ -1,4 +1,4 @@
1
- import { DBPatch, BaseCommonDB, CommonDB, CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, DBQuery, RunQueryResult } from '@naturalcycles/db-lib';
1
+ import { DBPatch, BaseCommonDB, CommonDB, CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, DBQuery, RunQueryResult, CommonDBSupport, CommonDBType } from '@naturalcycles/db-lib';
2
2
  import { AnyObjectWithId, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';
3
3
  import { ReadableTyped } from '@naturalcycles/nodejs-lib';
4
4
  import { Connection, Pool, PoolConfig, PoolConnection, QueryOptions } from 'mysql';
@@ -24,6 +24,8 @@ export interface MysqlDBCfg extends PoolConfig {
24
24
  logger?: CommonLogger;
25
25
  }
26
26
  export declare class MysqlDB extends BaseCommonDB implements CommonDB {
27
+ dbType: CommonDBType;
28
+ support: CommonDBSupport;
27
29
  constructor(cfg?: MysqlDBCfg);
28
30
  cfg: MysqlDBCfg & {
29
31
  logger: CommonLogger;
package/dist/mysql.db.js CHANGED
@@ -34,6 +34,12 @@ const typeCast = (field, next) => {
34
34
  class MysqlDB extends db_lib_1.BaseCommonDB {
35
35
  constructor(cfg = {}) {
36
36
  super();
37
+ this.dbType = db_lib_1.CommonDBType.relational;
38
+ this.support = {
39
+ ...db_lib_1.commonDBFullSupport,
40
+ updateSaveMethod: false,
41
+ transactions: false,
42
+ };
37
43
  this.cfg = {
38
44
  typeCast,
39
45
  // charset: 'utf8mb4', // for emoji support
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "prepare": "husky install"
5
5
  },
6
6
  "dependencies": {
7
- "@naturalcycles/db-lib": "^8.16.2",
7
+ "@naturalcycles/db-lib": "^9.1.0",
8
8
  "@naturalcycles/js-lib": "^14.47.0",
9
9
  "@naturalcycles/nodejs-lib": "^13.1.0",
10
10
  "@types/mysql": "^2.15.19",
@@ -36,7 +36,7 @@
36
36
  "engines": {
37
37
  "node": ">=16.15.0"
38
38
  },
39
- "version": "3.14.4",
39
+ "version": "3.14.5",
40
40
  "description": "MySQL client implementing CommonDB interface",
41
41
  "keywords": [
42
42
  "mysql",
package/src/index.ts CHANGED
@@ -1,8 +1,3 @@
1
- import { getDBAdapter } from './dbAdapter'
2
- import { MysqlDB, MysqlDBCfg, MysqlDBOptions, MysqlDBSaveOptions } from './mysql.db'
3
- import { MySQLKeyValueDB } from './mysqlKeyValueDB'
4
- import { jsonSchemaToMySQLDDL } from './schema/mysql.schema.util'
5
-
6
- export type { MysqlDBCfg, MysqlDBOptions, MysqlDBSaveOptions }
7
-
8
- export { MysqlDB, MySQLKeyValueDB, jsonSchemaToMySQLDDL, getDBAdapter }
1
+ export * from './mysql.db'
2
+ export * from './mysqlKeyValueDB'
3
+ export { jsonSchemaToMySQLDDL } from './schema/mysql.schema.util'
package/src/mysql.db.ts CHANGED
@@ -9,6 +9,9 @@ import {
9
9
  CommonDBSaveOptions,
10
10
  DBQuery,
11
11
  RunQueryResult,
12
+ CommonDBSupport,
13
+ commonDBFullSupport,
14
+ CommonDBType,
12
15
  } from '@naturalcycles/db-lib'
13
16
  import {
14
17
  _assert,
@@ -91,6 +94,14 @@ const typeCast: TypeCast = (field, next) => {
91
94
  }
92
95
 
93
96
  export class MysqlDB extends BaseCommonDB implements CommonDB {
97
+ override dbType = CommonDBType.relational
98
+
99
+ override support: CommonDBSupport = {
100
+ ...commonDBFullSupport,
101
+ updateSaveMethod: false,
102
+ transactions: false,
103
+ }
104
+
94
105
  constructor(cfg: MysqlDBCfg = {}) {
95
106
  super()
96
107
  this.cfg = {
@@ -352,7 +363,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
352
363
  /**
353
364
  * Limitation: always returns [], regardless of which rows are actually deleted
354
365
  */
355
- async deleteByIds<ROW extends ObjectWithId>(
366
+ override async deleteByIds<ROW extends ObjectWithId>(
356
367
  table: string,
357
368
  ids: ROW['id'][],
358
369
  _opt?: MysqlDBOptions,
@@ -1,2 +0,0 @@
1
- import { MysqlDB } from './mysql.db';
2
- export declare function getDBAdapter(cfgStr?: string): MysqlDB;
package/dist/dbAdapter.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDBAdapter = void 0;
4
- const mysql_db_1 = require("./mysql.db");
5
- function getDBAdapter(cfgStr = '{}') {
6
- const cfg = JSON.parse(cfgStr);
7
- return new mysql_db_1.MysqlDB(cfg);
8
- }
9
- exports.getDBAdapter = getDBAdapter;
package/src/dbAdapter.ts DELETED
@@ -1,6 +0,0 @@
1
- import { MysqlDB } from './mysql.db'
2
-
3
- export function getDBAdapter(cfgStr: string = '{}'): MysqlDB {
4
- const cfg = JSON.parse(cfgStr)
5
- return new MysqlDB(cfg)
6
- }