Comparing version 0.16.4 to 0.17.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.17.0](https://github.com/waitingsong/kmore/compare/v0.16.4...v0.17.0) (2020-06-07) | ||
### Features | ||
* **kmore:** define EnumClient for KnexConfig.client ([71ff719](https://github.com/waitingsong/kmore/commit/71ff719779c54238cb7924bd8c6c17f015a34fb8)) | ||
* **kmore:** define getCurrentTime() to retrieve time from database ([16119fb](https://github.com/waitingsong/kmore/commit/16119fbf3a7b48f4519bb8f92b3055fe4f56b2c9)) | ||
## [0.16.4](https://github.com/waitingsong/kmore/compare/v0.16.3...v0.16.4) (2020-06-06) | ||
@@ -8,0 +20,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 0.16.3 | ||
* @version 0.16.4 | ||
* @author waiting | ||
@@ -430,4 +430,44 @@ * @license MIT | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
(function (EnumClient) { | ||
EnumClient["pg"] = "pg"; | ||
EnumClient["mssql"] = "mssql"; | ||
EnumClient["mysql"] = "mysql"; | ||
EnumClient["mysql2"] = "mysql2"; | ||
EnumClient["sqlite3"] = "sqlite3"; | ||
EnumClient["oracledb"] = "oracledb"; | ||
})(exports.EnumClient || (exports.EnumClient = {})); | ||
async function getCurrentTime(dbh, clientType) { | ||
const res = await dbh.raw('SELECT now() AS currenttime;'); | ||
if (typeof clientType === 'string' && clientType) { | ||
switch (clientType) { | ||
case exports.EnumClient.pg: | ||
return parseRespCommon(res); | ||
case exports.EnumClient.mysql: | ||
return parseRespCommon(res); | ||
case exports.EnumClient.mysql2: | ||
return parseRespMysql2(res); | ||
default: | ||
throw new TypeError(`Unsupported client value: '${clientType}' for getCurrentTime(). | ||
Only ${exports.EnumClient.pg}, ${exports.EnumClient.mysql}, ${exports.EnumClient.mysql2} so far. | ||
`); | ||
} | ||
} | ||
else { | ||
throw new TypeError('Value of client is empty or not string'); | ||
} | ||
} | ||
function parseRespCommon(res) { | ||
return res.rows[0].currenttime; | ||
} | ||
function parseRespMysql2(res) { | ||
return res && res[0] && res[0][0] && res[0][0].currenttime | ||
? res[0][0].currenttime | ||
: ''; | ||
} | ||
exports.genTbListFromType = genTbListFromType; | ||
exports.getCurrentTime = getCurrentTime; | ||
exports.kmore = kmore; | ||
//# sourceMappingURL=index.cjs.js.map |
export * from './lib/index'; | ||
export * from './lib/model'; | ||
export * from './lib/helper'; | ||
export { genTbListFromType } from './lib/tables'; |
export * from './lib/index'; | ||
export * from './lib/model'; | ||
export * from './lib/helper'; | ||
// export { genTbListFromType } from 'kmore-types' | ||
export { genTbListFromType } from './lib/tables'; |
@@ -69,1 +69,9 @@ import { JointTable, Tables, MultiTableCols, MultiTableScopedCols, MultiTableAliasCols, KTablesBase, Options, DbPropKeys, TTables, TableAliasCols, ColAliasType, KnexColumnsParma } from 'kmore-types'; | ||
} | ||
export declare enum EnumClient { | ||
pg = "pg", | ||
mssql = "mssql", | ||
mysql = "mysql", | ||
mysql2 = "mysql2", | ||
sqlite3 = "sqlite3", | ||
oracledb = "oracledb" | ||
} |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { DbPropKeys, } from 'kmore-types'; | ||
export var EnumClient; | ||
(function (EnumClient) { | ||
EnumClient["pg"] = "pg"; | ||
EnumClient["mssql"] = "mssql"; | ||
EnumClient["mysql"] = "mysql"; | ||
EnumClient["mysql2"] = "mysql2"; | ||
EnumClient["sqlite3"] = "sqlite3"; | ||
EnumClient["oracledb"] = "oracledb"; | ||
})(EnumClient || (EnumClient = {})); |
{ | ||
"name": "kmore", | ||
"author": "waiting", | ||
"version": "0.16.4", | ||
"version": "0.17.0", | ||
"description": "A Knex little more typed factory of SQL query builder powed by TypeScript, with auto-generated type-safe tables accessor for Node.js", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"@waiting/shared-types": "3", | ||
"kmore-types": "^0.16.4", | ||
"kmore-types": "^0.17.0", | ||
"rxjs": "^6.5.2" | ||
@@ -99,3 +99,3 @@ }, | ||
}, | ||
"gitHead": "ded027cfe469f2ed1082620814e2b4486382b27d" | ||
"gitHead": "a7ec4ea8a805aa645d54979d88ba3c83def65ba1" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106115
27
1205
+ Addedkmore-types@0.17.1(transitive)
- Removedkmore-types@0.16.4(transitive)
Updatedkmore-types@^0.17.0