@klapeks/micro-db-utils 0.0.15 → 0.0.16
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.
|
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.AbstractSelectHandler = void 0;
|
|
40
40
|
var iso_date_time_1 = require("../utils/iso.date.time");
|
|
41
|
+
var micro_sql_1 = require("../micro.sql");
|
|
41
42
|
var AbstractSelectHandler = /** @class */ (function () {
|
|
42
43
|
function AbstractSelectHandler(options) {
|
|
43
44
|
this.options = options;
|
|
@@ -105,17 +106,18 @@ var AbstractSelectHandler = /** @class */ (function () {
|
|
|
105
106
|
switch (_r.label) {
|
|
106
107
|
case 0:
|
|
107
108
|
stat = function (fromDate, time) { return __awaiter(_this, void 0, void 0, function () {
|
|
108
|
-
var isoDate, sum;
|
|
109
|
+
var expr, isoDate, sum;
|
|
109
110
|
var _a;
|
|
110
111
|
return __generator(this, function (_b) {
|
|
111
112
|
switch (_b.label) {
|
|
112
113
|
case 0:
|
|
114
|
+
expr = micro_sql_1.MicroSQL.timeExpressions(this.getDatabaseType());
|
|
113
115
|
if (typeof fromDate == 'function') {
|
|
114
116
|
fromDate = (0, iso_date_time_1.dateFromNow)(fromDate);
|
|
115
117
|
}
|
|
116
118
|
isoDate = (0, iso_date_time_1.toISODate)(fromDate, 'yyyy-mm-dd');
|
|
117
119
|
return [4 /*yield*/, this.runSQL_One("\n SELECT SUM(".concat(sumField, ") as sum\n FROM ").concat(this.getTableName(), "\n WHERE ").concat(time ? "createdAt >= '".concat(isoDate, " ").concat(time, "'")
|
|
118
|
-
:
|
|
120
|
+
: (expr.date('createdAt') + ' >= ' + expr.date("'".concat(isoDate, "'"))), "\n ").concat(strWhere ? ('AND (' + strWhere + ')') : '', "\n "))];
|
|
119
121
|
case 1:
|
|
120
122
|
sum = ((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.sum) || 0;
|
|
121
123
|
return [2 /*return*/, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ISQLCommandAdapter } from "./abstract.sql.command";
|
|
2
2
|
import { MicroColumnTypeObject } from "../column.type.parser";
|
|
3
3
|
export declare class SQLTablesCommands {
|
|
4
|
+
static renameTable(old_name: string, new_name: string): ISQLCommandAdapter;
|
|
4
5
|
static tableInfo(database: string, table: string): ISQLCommandAdapter;
|
|
5
6
|
static createTable(options: {
|
|
6
7
|
table: string;
|
|
@@ -5,6 +5,14 @@ var column_type_parser_1 = require("../column.type.parser");
|
|
|
5
5
|
var SQLTablesCommands = /** @class */ (function () {
|
|
6
6
|
function SQLTablesCommands() {
|
|
7
7
|
}
|
|
8
|
+
SQLTablesCommands.renameTable = function (old_name, new_name) {
|
|
9
|
+
return {
|
|
10
|
+
toMySQL: function () { return "RENAME TABLE `".concat(old_name, "` TO `").concat(new_name, "`;"); },
|
|
11
|
+
toMSSQL: function () { return "EXEC sp_rename '".concat(old_name, "', '").concat(new_name, "';"); },
|
|
12
|
+
// PG: ALTER TABLE "old_name" RENAME TO "new_name";
|
|
13
|
+
// SQLITE: ALTER TABLE "old_name" RENAME TO "new_name";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
8
16
|
SQLTablesCommands.tableInfo = function (database, table) {
|
|
9
17
|
return {
|
|
10
18
|
toMySQL: function () { return [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klapeks/micro-db-utils",
|
|
3
3
|
"description": "klapeks utils for db and other storages",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"author": "Klapeks",
|
|
7
7
|
"license": "ISC",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@aws-sdk/client-s3": "^3.842.0",
|
|
23
23
|
"@aws-sdk/s3-request-presigner": "^3.844.0",
|
|
24
24
|
"@klapeks/api-creation-tools": "^0.0.7",
|
|
25
|
-
"@klapeks/utils": "^0.1.
|
|
25
|
+
"@klapeks/utils": "^0.1.8",
|
|
26
26
|
"@types/mssql": "^12.3.0",
|
|
27
27
|
"@types/node": "^18.11.18",
|
|
28
28
|
"axios": "^1.7.7",
|