@klapeks/micro-db-utils 0.0.13 → 0.0.14
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/migrations/super.migrations.js +0 -1
- package/dist/sql/column.type.parser.d.ts +2 -0
- package/dist/sql/column.type.parser.js +39 -0
- package/dist/sql/commands/alter.commands.d.ts +2 -0
- package/dist/sql/commands/alter.commands.js +12 -0
- package/dist/sql/commands/edit-data.commands.d.ts +1 -0
- package/dist/sql/commands/edit-data.commands.js +33 -1
- package/dist/sql/commands/tables.commands.js +1 -1
- package/dist/sql/commands/time.commands.d.ts +1 -0
- package/dist/sql/commands/time.commands.js +8 -1
- package/dist/sql/index.d.ts +2 -0
- package/dist/sql/index.js +2 -0
- package/dist/sql/raw.where.utils.d.ts +2 -0
- package/dist/sql/raw.where.utils.js +35 -0
- package/dist/utils/columns.types.d.ts +6 -91
- package/dist/utils/where.utils.d.ts +1 -0
- package/dist/utils/where.utils.js +6 -6
- package/package.json +2 -2
|
@@ -236,7 +236,6 @@ var SuperMigrations = /** @class */ (function () {
|
|
|
236
236
|
.runSQL_One(tables_commands_1.SQLTablesCommands.tableInfo(options.database, SuperMigrations.migrationTableName))];
|
|
237
237
|
case 4:
|
|
238
238
|
_existsMigrationTable = _d.sent();
|
|
239
|
-
logger.debug("Migrations table info:", _existsMigrationTable);
|
|
240
239
|
if (!!_existsMigrationTable) return [3 /*break*/, 6];
|
|
241
240
|
// creating migration table if not exists
|
|
242
241
|
logger.log("Creating migration table..");
|
|
@@ -6,6 +6,8 @@ export interface MicroColumnTypeObject {
|
|
|
6
6
|
primary?: boolean;
|
|
7
7
|
length?: number;
|
|
8
8
|
nullable?: boolean;
|
|
9
|
+
default?: any;
|
|
10
|
+
generated?: true | "increment";
|
|
9
11
|
}
|
|
10
12
|
export declare namespace MicroColumnTypeObject {
|
|
11
13
|
function toSQLQuery(dbType: DatabaseOptions['type'], options: MicroColumnTypeObject, queryType?: "create-table" | "alter-column"): string;
|
|
@@ -38,10 +38,49 @@ var MicroColumnTypeObject;
|
|
|
38
38
|
var columnLength = options.length || ((columnType === 'varchar'
|
|
39
39
|
|| columnType === 'nvarchar') ? 255 : undefined);
|
|
40
40
|
var str = columnType + (columnLength ? "(".concat(columnLength, ")") : '');
|
|
41
|
+
// nullable
|
|
41
42
|
if (options.nullable)
|
|
42
43
|
str += ' NULL';
|
|
43
44
|
else
|
|
44
45
|
str += ' NOT NULL';
|
|
46
|
+
// auto increment
|
|
47
|
+
if (options.generated) {
|
|
48
|
+
if (dbType === 'mssql')
|
|
49
|
+
str += ' IDENTITY';
|
|
50
|
+
else if (dbType === 'mysql')
|
|
51
|
+
str += ' AUTO_INCREMENT';
|
|
52
|
+
else
|
|
53
|
+
throw "options.generated is not supported yet for " + dbType;
|
|
54
|
+
}
|
|
55
|
+
// default
|
|
56
|
+
if (options.default !== undefined) {
|
|
57
|
+
var value = options.default;
|
|
58
|
+
if (value === null || value === 'null' || value === 'NULL') {
|
|
59
|
+
value = "NULL";
|
|
60
|
+
}
|
|
61
|
+
else if (typeof value === 'number') {
|
|
62
|
+
value = value.toString(); // :)
|
|
63
|
+
}
|
|
64
|
+
else if (typeof value === 'boolean') {
|
|
65
|
+
if (dbType === 'mssql') {
|
|
66
|
+
value = value ? '1' : '0';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
value = value ? "true" : "false";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (typeof value === 'string') {
|
|
73
|
+
value = "'".concat(value.replace(/'/g, "''"), "'");
|
|
74
|
+
}
|
|
75
|
+
else if (typeof value === 'object') {
|
|
76
|
+
value = "'".concat(JSON.stringify(value), "'");
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
value = "'".concat(value, "'");
|
|
80
|
+
}
|
|
81
|
+
str += " DEFAULT ".concat(value);
|
|
82
|
+
}
|
|
83
|
+
// primary key
|
|
45
84
|
if (queryType === 'create-table') {
|
|
46
85
|
if (options.primary) {
|
|
47
86
|
str += ' PRIMARY KEY';
|
|
@@ -3,6 +3,8 @@ import { ISQLCommandAdapter } from "./abstract.sql.command";
|
|
|
3
3
|
export declare class SQLAlterCommand {
|
|
4
4
|
private readonly table;
|
|
5
5
|
constructor(table: string);
|
|
6
|
+
array(cb: (t: SQLAlterCommand) => ISQLCommandAdapter[]): ISQLCommandAdapter[];
|
|
6
7
|
renameColumn(old_name: string, new_name: string): ISQLCommandAdapter;
|
|
7
8
|
changeColumnType(column: string, type: MicroColumnTypeObject): ISQLCommandAdapter;
|
|
9
|
+
addColumn(column: string, type: MicroColumnTypeObject): ISQLCommandAdapter;
|
|
8
10
|
}
|
|
@@ -6,6 +6,9 @@ var SQLAlterCommand = /** @class */ (function () {
|
|
|
6
6
|
function SQLAlterCommand(table) {
|
|
7
7
|
this.table = table;
|
|
8
8
|
}
|
|
9
|
+
SQLAlterCommand.prototype.array = function (cb) {
|
|
10
|
+
return cb(this);
|
|
11
|
+
};
|
|
9
12
|
SQLAlterCommand.prototype.renameColumn = function (old_name, new_name) {
|
|
10
13
|
var _this = this;
|
|
11
14
|
return {
|
|
@@ -22,6 +25,15 @@ var SQLAlterCommand = /** @class */ (function () {
|
|
|
22
25
|
+ column_type_parser_1.MicroColumnTypeObject.toSQLQuery('mssql', type, 'alter-column') + ';'; }
|
|
23
26
|
};
|
|
24
27
|
};
|
|
28
|
+
SQLAlterCommand.prototype.addColumn = function (column, type) {
|
|
29
|
+
var _this = this;
|
|
30
|
+
return {
|
|
31
|
+
toMySQL: function () { return "ALTER TABLE `".concat(_this.table, "` ADD COLUMN `").concat(column, "` ")
|
|
32
|
+
+ column_type_parser_1.MicroColumnTypeObject.toSQLQuery('mysql', type, 'alter-column') + ';'; },
|
|
33
|
+
toMSSQL: function () { return "ALTER TABLE [".concat(_this.table, "] ADD [").concat(column, "] ")
|
|
34
|
+
+ column_type_parser_1.MicroColumnTypeObject.toSQLQuery('mssql', type, 'alter-column') + ';'; }
|
|
35
|
+
};
|
|
36
|
+
};
|
|
25
37
|
return SQLAlterCommand;
|
|
26
38
|
}());
|
|
27
39
|
exports.SQLAlterCommand = SQLAlterCommand;
|
|
@@ -2,5 +2,6 @@ import { ISQLCommandAdapter } from "./abstract.sql.command";
|
|
|
2
2
|
export declare class SQLEditDataCommands {
|
|
3
3
|
private readonly table;
|
|
4
4
|
constructor(table: string);
|
|
5
|
+
update(data: any, where: any): ISQLCommandAdapter;
|
|
5
6
|
upsert(data: any, idKeys: string[]): ISQLCommandAdapter;
|
|
6
7
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
14
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
15
|
if (ar || !(i in from)) {
|
|
@@ -10,10 +21,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
10
21
|
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.SQLEditDataCommands = void 0;
|
|
24
|
+
var raw_where_utils_1 = require("../raw.where.utils");
|
|
13
25
|
var SQLEditDataCommands = /** @class */ (function () {
|
|
14
26
|
function SQLEditDataCommands(table) {
|
|
15
27
|
this.table = table;
|
|
16
28
|
}
|
|
29
|
+
SQLEditDataCommands.prototype.update = function (data, where) {
|
|
30
|
+
var _this = this;
|
|
31
|
+
return {
|
|
32
|
+
toMySQL: function () { return ({
|
|
33
|
+
query: "\n UPDATE `".concat(_this.table, "`\n SET ").concat(Object.keys(data).map(function (key) { return "`".concat(key, "` = ?"); }).join(','), "\n WHERE ").concat(Object.keys(where).map(function (key) { return (0, raw_where_utils_1.converWhereQuery)('mysql', key, data[key], '?'); }).join(' AND '), ";\n "),
|
|
34
|
+
params: __spreadArray(__spreadArray([], Object.values(data), true), Object.values(where), true)
|
|
35
|
+
}); },
|
|
36
|
+
toMSSQL: function () { return ({
|
|
37
|
+
query: "\n UPDATE [".concat(_this.table, "] \n SET ").concat(Object.keys(data).map(function (key) { return "[".concat(key, "] = @").concat(key); }).join(','), "\n WHERE ").concat(Object.keys(where).map(function (key) { return (0, raw_where_utils_1.converWhereQuery)('mssql', key, data[key], 'where_' + key); }).join(' AND '), ";\n "),
|
|
38
|
+
params: (function () {
|
|
39
|
+
var params = __assign({}, data);
|
|
40
|
+
for (var _i = 0, _a = Object.keys(where); _i < _a.length; _i++) {
|
|
41
|
+
var key = _a[_i];
|
|
42
|
+
params['where_' + key] = where[key];
|
|
43
|
+
}
|
|
44
|
+
return params;
|
|
45
|
+
})()
|
|
46
|
+
}); },
|
|
47
|
+
};
|
|
48
|
+
};
|
|
17
49
|
SQLEditDataCommands.prototype.upsert = function (data, idKeys) {
|
|
18
50
|
var _this = this;
|
|
19
51
|
if (!data)
|
|
@@ -38,7 +70,7 @@ var SQLEditDataCommands = /** @class */ (function () {
|
|
|
38
70
|
params: __spreadArray(__spreadArray([], Object.values(data), true), Object.values(toUpdObj), true)
|
|
39
71
|
}); },
|
|
40
72
|
toMSSQL: function () { return ({
|
|
41
|
-
query: "\n UPDATE [".concat(_this.table, "] \n SET ").concat(Object.keys(toUpdObj).map(function (key) { return "[".concat(key, "] = @").concat(key); }).join(','), "\n WHERE ").concat(idKeys.map(function (key) { return
|
|
73
|
+
query: "\n UPDATE [".concat(_this.table, "] \n SET ").concat(Object.keys(toUpdObj).map(function (key) { return "[".concat(key, "] = @").concat(key); }).join(','), "\n WHERE ").concat(idKeys.map(function (key) { return (0, raw_where_utils_1.converWhereQuery)('mssql', key, data[key], key); }).join(' AND '), ";\n\n IF @@ROWCOUNT = 0 INSERT INTO [").concat(_this.table, "]\n (").concat(dataKeys.map(function (a) { return "[".concat(a, "]"); }).join(', '), ")\n VALUES (").concat(dataKeys.map(function (key) { return '@' + key; }).join(', '), ");\n "),
|
|
42
74
|
params: data
|
|
43
75
|
}); },
|
|
44
76
|
};
|
|
@@ -51,7 +51,7 @@ var SQLTablesCommands = /** @class */ (function () {
|
|
|
51
51
|
SQLTablesCommands.getTablesSizes = function (database) {
|
|
52
52
|
return {
|
|
53
53
|
toMySQL: function () { return "\n SELECT \n TABLE_NAME as 'table_name', \n (DATA_LENGTH / 1024) as 'data_kb', \n (INDEX_LENGTH / 1024) as 'index_kb'\n FROM information_schema.TABLES\n WHERE table_schema = '".concat(database, "'\n ORDER BY (data_kb + index_kb) DESC;\n "); },
|
|
54
|
-
toMSSQL: function () { return "\n SELECT\n t.name AS table_name,\n
|
|
54
|
+
toMSSQL: function () { return "\n SELECT * FROM (\n SELECT\n t.name AS table_name,\n SUM(ps.in_row_data_page_count + ps.lob_used_page_count\n + ps.row_overflow_used_page_count\n ) * 8 AS data_kb,\n SUM(ps.used_page_count - ps.in_row_data_page_count\n - ps.lob_used_page_count - ps.row_overflow_used_page_count\n ) * 8 AS index_kb\n FROM sys.tables t\n JOIN sys.dm_db_partition_stats ps\n ON t.object_id = ps.object_id\n GROUP BY t.name\n ) t ORDER BY (data_kb + index_kb) DESC;\n "; },
|
|
55
55
|
// postgress
|
|
56
56
|
// SELECT
|
|
57
57
|
// relname AS table_name,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQLTimeCommandsExpressions = void 0;
|
|
4
|
+
var iso_date_time_1 = require("../../utils/iso.date.time");
|
|
4
5
|
var SQLTimeCommandsExpressions = /** @class */ (function () {
|
|
5
6
|
function SQLTimeCommandsExpressions(dbtype) {
|
|
6
7
|
this.dbtype = dbtype;
|
|
@@ -17,7 +18,13 @@ var SQLTimeCommandsExpressions = /** @class */ (function () {
|
|
|
17
18
|
|| this.dbtype == 'postgres') {
|
|
18
19
|
return "CAST(".concat(expr, " AS DATE)");
|
|
19
20
|
}
|
|
20
|
-
return "
|
|
21
|
+
return "date(".concat(expr, ")");
|
|
22
|
+
};
|
|
23
|
+
SQLTimeCommandsExpressions.prototype.dateFromToWhere = function (dateAlias, from, to) {
|
|
24
|
+
var sql = this.date(dateAlias) + " >= " + "'" + (0, iso_date_time_1.toISODate)(from, "yyyy-mm-dd") + "'";
|
|
25
|
+
if (to)
|
|
26
|
+
sql += ' AND ' + this.date(dateAlias) + " <= " + "'" + (0, iso_date_time_1.toISODate)(to, "yyyy-mm-dd") + "'";
|
|
27
|
+
return sql;
|
|
21
28
|
};
|
|
22
29
|
return SQLTimeCommandsExpressions;
|
|
23
30
|
}());
|
package/dist/sql/index.d.ts
CHANGED
package/dist/sql/index.js
CHANGED
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./commands"), exports);
|
|
18
18
|
__exportStar(require("./connections"), exports);
|
|
19
|
+
__exportStar(require("./raw.where.utils"), exports);
|
|
20
|
+
__exportStar(require("./column.type.parser"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.converWhereQuery = void 0;
|
|
4
|
+
var typeorm_1 = require("typeorm");
|
|
5
|
+
function sqlQuoteKey(dbType, str) {
|
|
6
|
+
if (dbType === 'mysql')
|
|
7
|
+
return "`".concat(str, "`");
|
|
8
|
+
if (dbType === 'mssql')
|
|
9
|
+
return "[".concat(str, "]");
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
function converWhereQuery(dbType, key, value, keyAlias) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (value instanceof typeorm_1.FindOperator) {
|
|
15
|
+
if (value.type === 'isNull') {
|
|
16
|
+
return sqlQuoteKey(dbType, key) + ' IS NULL';
|
|
17
|
+
}
|
|
18
|
+
if (value.type === 'not') {
|
|
19
|
+
if (((_a = value.child) === null || _a === void 0 ? void 0 : _a.type) === 'isNull') {
|
|
20
|
+
return sqlQuoteKey(dbType, key) + ' IS NOT NULL';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (value === null) {
|
|
25
|
+
return sqlQuoteKey(dbType, key) + ' IS NULL';
|
|
26
|
+
}
|
|
27
|
+
if (keyAlias === '?' || dbType === 'mysql') {
|
|
28
|
+
return sqlQuoteKey(dbType, key) + " = ?";
|
|
29
|
+
}
|
|
30
|
+
if (dbType === 'mssql') {
|
|
31
|
+
return "[".concat(key, "] = @").concat(keyAlias || key);
|
|
32
|
+
}
|
|
33
|
+
return sqlQuoteKey(dbType, key) + " = :".concat(keyAlias || key);
|
|
34
|
+
}
|
|
35
|
+
exports.converWhereQuery = converWhereQuery;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import {
|
|
2
|
+
import { EntitySchemaOptions } from "typeorm";
|
|
3
|
+
import { MicroColumnTypeObject } from "../sql/column.type.parser";
|
|
3
4
|
export type RequiredColumns<T> = Required<EntitySchemaOptions<T>['columns']>;
|
|
4
5
|
export type RequiredMongoColumns<T> = Required<mongoose.Schema<T>>;
|
|
5
6
|
export declare function createRelation(target: string, type: "one-to-many" | "one-to-one", inverseSide: string, cascade?: boolean): {
|
|
@@ -16,93 +17,7 @@ export declare const MULTISQL_COLUMNS_TYPES: {
|
|
|
16
17
|
float64: "float" | "double";
|
|
17
18
|
json: "simple-json" | "json";
|
|
18
19
|
};
|
|
19
|
-
export declare const FloatingColumn:
|
|
20
|
-
export declare const NullableFloatingColumn:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
primary?: boolean | undefined;
|
|
24
|
-
objectId?: boolean | undefined;
|
|
25
|
-
createDate?: boolean | undefined;
|
|
26
|
-
updateDate?: boolean | undefined;
|
|
27
|
-
deleteDate?: boolean | undefined;
|
|
28
|
-
version?: boolean | undefined;
|
|
29
|
-
treeChildrenCount?: boolean | undefined;
|
|
30
|
-
treeLevel?: boolean | undefined;
|
|
31
|
-
virtualProperty?: boolean | undefined;
|
|
32
|
-
type: ColumnType;
|
|
33
|
-
name?: string | undefined;
|
|
34
|
-
length?: string | number | undefined;
|
|
35
|
-
width?: number | undefined;
|
|
36
|
-
readonly?: boolean | undefined;
|
|
37
|
-
update?: boolean | undefined;
|
|
38
|
-
select?: boolean | undefined;
|
|
39
|
-
insert?: boolean | undefined;
|
|
40
|
-
generated?: true | "uuid" | "rowid" | "increment" | undefined;
|
|
41
|
-
unique?: boolean | undefined;
|
|
42
|
-
columnDefinition?: string | undefined;
|
|
43
|
-
comment?: string | undefined;
|
|
44
|
-
onUpdate?: string | undefined;
|
|
45
|
-
precision?: number | undefined;
|
|
46
|
-
scale?: number | undefined;
|
|
47
|
-
zerofill?: boolean | undefined;
|
|
48
|
-
unsigned?: boolean | undefined;
|
|
49
|
-
charset?: string | undefined;
|
|
50
|
-
collation?: string | undefined;
|
|
51
|
-
enum?: Object | any[] | undefined;
|
|
52
|
-
enumName?: string | undefined;
|
|
53
|
-
asExpression?: string | undefined;
|
|
54
|
-
generatedType?: "VIRTUAL" | "STORED" | undefined;
|
|
55
|
-
hstoreType?: "string" | "object" | undefined;
|
|
56
|
-
array?: boolean | undefined;
|
|
57
|
-
transformer?: import("typeorm").ValueTransformer | import("typeorm").ValueTransformer[] | undefined;
|
|
58
|
-
primaryKeyConstraintName?: string | undefined;
|
|
59
|
-
foreignKey?: import("typeorm/entity-schema/EntitySchemaColumnForeignKeyOptions").EntitySchemaColumnForeignKeyOptions | undefined;
|
|
60
|
-
query?: ((alias: string) => string) | undefined;
|
|
61
|
-
spatialFeatureType?: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection" | undefined;
|
|
62
|
-
srid?: number | undefined;
|
|
63
|
-
};
|
|
64
|
-
export declare const Float64Column: EntitySchemaColumnOptions;
|
|
65
|
-
export declare const NullableFloat64Column: {
|
|
66
|
-
default: null;
|
|
67
|
-
nullable: boolean;
|
|
68
|
-
primary?: boolean | undefined;
|
|
69
|
-
objectId?: boolean | undefined;
|
|
70
|
-
createDate?: boolean | undefined;
|
|
71
|
-
updateDate?: boolean | undefined;
|
|
72
|
-
deleteDate?: boolean | undefined;
|
|
73
|
-
version?: boolean | undefined;
|
|
74
|
-
treeChildrenCount?: boolean | undefined;
|
|
75
|
-
treeLevel?: boolean | undefined;
|
|
76
|
-
virtualProperty?: boolean | undefined;
|
|
77
|
-
type: ColumnType;
|
|
78
|
-
name?: string | undefined;
|
|
79
|
-
length?: string | number | undefined;
|
|
80
|
-
width?: number | undefined;
|
|
81
|
-
readonly?: boolean | undefined;
|
|
82
|
-
update?: boolean | undefined;
|
|
83
|
-
select?: boolean | undefined;
|
|
84
|
-
insert?: boolean | undefined;
|
|
85
|
-
generated?: true | "uuid" | "rowid" | "increment" | undefined;
|
|
86
|
-
unique?: boolean | undefined;
|
|
87
|
-
columnDefinition?: string | undefined;
|
|
88
|
-
comment?: string | undefined;
|
|
89
|
-
onUpdate?: string | undefined;
|
|
90
|
-
precision?: number | undefined;
|
|
91
|
-
scale?: number | undefined;
|
|
92
|
-
zerofill?: boolean | undefined;
|
|
93
|
-
unsigned?: boolean | undefined;
|
|
94
|
-
charset?: string | undefined;
|
|
95
|
-
collation?: string | undefined;
|
|
96
|
-
enum?: Object | any[] | undefined;
|
|
97
|
-
enumName?: string | undefined;
|
|
98
|
-
asExpression?: string | undefined;
|
|
99
|
-
generatedType?: "VIRTUAL" | "STORED" | undefined;
|
|
100
|
-
hstoreType?: "string" | "object" | undefined;
|
|
101
|
-
array?: boolean | undefined;
|
|
102
|
-
transformer?: import("typeorm").ValueTransformer | import("typeorm").ValueTransformer[] | undefined;
|
|
103
|
-
primaryKeyConstraintName?: string | undefined;
|
|
104
|
-
foreignKey?: import("typeorm/entity-schema/EntitySchemaColumnForeignKeyOptions").EntitySchemaColumnForeignKeyOptions | undefined;
|
|
105
|
-
query?: ((alias: string) => string) | undefined;
|
|
106
|
-
spatialFeatureType?: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection" | undefined;
|
|
107
|
-
srid?: number | undefined;
|
|
108
|
-
};
|
|
20
|
+
export declare const FloatingColumn: MicroColumnTypeObject;
|
|
21
|
+
export declare const NullableFloatingColumn: MicroColumnTypeObject;
|
|
22
|
+
export declare const Float64Column: MicroColumnTypeObject;
|
|
23
|
+
export declare const NullableFloat64Column: MicroColumnTypeObject;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ObjectLiteral, SelectQueryBuilder } from "typeorm";
|
|
2
2
|
export declare function addTimedWhere<T extends ObjectLiteral>(builder: SelectQueryBuilder<T>, dateAlias: string, from: Date, to?: Date): SelectQueryBuilder<T>;
|
|
3
|
+
/** @deprecated use MicroSQL.timeExpressions(dbType).dateFromToWhere(...) */
|
|
3
4
|
export declare function rawTimedWhere(dateAlias: string, from: Date, to?: Date): string;
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rawTimedWhere = exports.addTimedWhere = void 0;
|
|
4
4
|
var iso_date_time_1 = require("./iso.date.time");
|
|
5
|
+
var micro_sql_1 = require("../micro.sql");
|
|
5
6
|
function addTimedWhere(builder, dateAlias, from, to) {
|
|
6
|
-
|
|
7
|
+
var expr = micro_sql_1.MicroSQL.timeExpressions(builder.connection.options.type);
|
|
8
|
+
builder.andWhere(expr.date(dateAlias) + ' >= ' + expr.date(':from'), {
|
|
7
9
|
from: (0, iso_date_time_1.toISODate)(from, "yyyy-mm-dd")
|
|
8
10
|
});
|
|
9
11
|
if (to)
|
|
10
|
-
builder.andWhere(
|
|
12
|
+
builder.andWhere(expr.date(dateAlias) + ' <= ' + expr.date(':to'), {
|
|
11
13
|
to: (0, iso_date_time_1.toISODate)(to, "yyyy-mm-dd")
|
|
12
14
|
});
|
|
13
15
|
return builder;
|
|
14
16
|
}
|
|
15
17
|
exports.addTimedWhere = addTimedWhere;
|
|
18
|
+
/** @deprecated use MicroSQL.timeExpressions(dbType).dateFromToWhere(...) */
|
|
16
19
|
function rawTimedWhere(dateAlias, from, to) {
|
|
17
|
-
|
|
18
|
-
if (to)
|
|
19
|
-
sql += "AND date(" + dateAlias + ") <= date('" + (0, iso_date_time_1.toISODate)(to, "yyyy-mm-dd") + "')";
|
|
20
|
-
return sql;
|
|
20
|
+
return micro_sql_1.MicroSQL.timeExpressions('mysql').dateFromToWhere(dateAlias, from, to);
|
|
21
21
|
}
|
|
22
22
|
exports.rawTimedWhere = rawTimedWhere;
|
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.14",
|
|
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.6",
|
|
26
26
|
"@types/mssql": "^12.3.0",
|
|
27
27
|
"@types/node": "^18.11.18",
|
|
28
28
|
"axios": "^1.7.7",
|