fib-orm 2.0.0 → 2.1.0
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/lib/cli/commands/ddlFrom.d.ts +1 -1
- package/lib/cli/commands/ddlFrom.js +1 -0
- package/lib/cli/commands/dumpModel.d.ts +1 -1
- package/lib/cli/commands/dumpModel.js +1 -0
- package/lib/cli/commands/escape.d.ts +1 -1
- package/lib/cli/commands/escape.js +1 -0
- package/lib/cli/commands/spinner.d.ts +1 -1
- package/lib/cli/commands/spinner.js +1 -0
- package/lib/cli/commands/upgrade.d.ts +1 -1
- package/lib/cli/commands/upgrade.js +1 -0
- package/lib/cli/helpers/ddl.d.ts +1 -1
- package/lib/cli/helpers/ddl.js +3 -3
- package/lib/cli/helpers/package.d.ts +0 -1
- package/lib/cli/helpers/package.js +4 -4
- package/lib/cli/index.js +1 -0
- package/lib/db-driver/Typo.d.ts +0 -1
- package/lib/db-driver/Typo.js +1 -0
- package/lib/db-driver/built-ins/base.class.d.ts +0 -5
- package/lib/db-driver/built-ins/base.class.js +1 -0
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-dm.js +1 -0
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-mongodb.js +1 -0
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-mysql.js +1 -0
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-postgresql.js +1 -0
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-redis.js +1 -0
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-sqlite.js +1 -0
- package/lib/db-driver/index.js +1 -0
- package/lib/db-driver/utils.js +13 -13
- package/lib/knex/knex.js +1 -0
- package/lib/knex/sandbox.js +1 -0
- package/lib/orm/Adapters.js +3 -3
- package/lib/orm/AggregateFunctions.js +1 -0
- package/lib/orm/Associations/Extend.js +4 -4
- package/lib/orm/Associations/Many.d.ts +0 -1
- package/lib/orm/Associations/Many.js +6 -6
- package/lib/orm/Associations/One.js +4 -4
- package/lib/orm/Associations/_utils.d.ts +0 -1
- package/lib/orm/Associations/_utils.js +8 -7
- package/lib/orm/ChainFind.js +1 -0
- package/lib/orm/ChainInstance.js +1 -0
- package/lib/orm/Debug.js +4 -4
- package/lib/orm/Drivers/DB/base.d.ts +0 -1
- package/lib/orm/Drivers/DB/base.js +1 -0
- package/lib/orm/Drivers/DB/dm.d.ts +0 -2
- package/lib/orm/Drivers/DB/dm.js +1 -0
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DB/mysql.js +1 -0
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -2
- package/lib/orm/Drivers/DB/postgres.js +1 -0
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -2
- package/lib/orm/Drivers/DB/sqlite3.js +1 -0
- package/lib/orm/Drivers/DML/_ddl-sql.js +1 -0
- package/lib/orm/Drivers/DML/_dml-helpers.js +6 -6
- package/lib/orm/Drivers/DML/_shared.js +5 -4
- package/lib/orm/Drivers/DML/_utils.js +7 -7
- package/lib/orm/Drivers/DML/constants.js +1 -0
- package/lib/orm/Drivers/DML/dm.js +1 -0
- package/lib/orm/Drivers/DML/index.js +1 -0
- package/lib/orm/Drivers/DML/mysql.js +1 -0
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -1
- package/lib/orm/Drivers/DML/postgres.js +1 -0
- package/lib/orm/Drivers/DML/sqlite.js +1 -0
- package/lib/orm/Error.js +2 -1
- package/lib/orm/Helpers.js +22 -21
- package/lib/orm/Hook.js +1 -0
- package/lib/orm/Instance.js +1 -0
- package/lib/orm/LazyLoad.js +2 -2
- package/lib/orm/Model.d.ts +1 -2
- package/lib/orm/Model.js +7 -4
- package/lib/orm/ORM.js +1 -0
- package/lib/orm/Patch/fib-cache.d.ts +0 -1
- package/lib/orm/Patch/plugin.js +2 -1
- package/lib/orm/Property.js +2 -2
- package/lib/orm/Settings.js +3 -2
- package/lib/orm/Singleton.js +1 -0
- package/lib/orm/Typo/Adapter.js +1 -0
- package/lib/orm/Typo/DMLDriver.d.ts +0 -1
- package/lib/orm/Typo/DMLDriver.js +1 -0
- package/lib/orm/Typo/Db.d.ts +0 -3
- package/lib/orm/Typo/Db.js +1 -0
- package/lib/orm/Typo/Error.d.ts +0 -2
- package/lib/orm/Typo/Error.js +1 -0
- package/lib/orm/Typo/ORM.d.ts +0 -2
- package/lib/orm/Typo/ORM.js +1 -0
- package/lib/orm/Typo/Validators.d.ts +0 -1
- package/lib/orm/Typo/Validators.js +1 -0
- package/lib/orm/Typo/_common.d.ts +0 -1
- package/lib/orm/Typo/_common.js +1 -0
- package/lib/orm/Typo/assoc.js +1 -0
- package/lib/orm/Typo/hook.js +1 -0
- package/lib/orm/Typo/instance.d.ts +0 -1
- package/lib/orm/Typo/instance.js +1 -0
- package/lib/orm/Typo/model.d.ts +0 -2
- package/lib/orm/Typo/model.js +2 -1
- package/lib/orm/Typo/patch.js +1 -0
- package/lib/orm/Typo/property.js +1 -0
- package/lib/orm/Typo/query.js +1 -0
- package/lib/orm/Typo/settings.js +2 -1
- package/lib/orm/Typo/synchronous.js +1 -0
- package/lib/orm/Utilities.d.ts +1 -2
- package/lib/orm/Utilities.js +60 -60
- package/lib/orm/Validators.d.ts +0 -1
- package/lib/orm/Validators.js +4 -3
- package/lib/orm/Where/common.js +2 -2
- package/lib/orm/Where/filterDate.js +2 -2
- package/lib/orm/index.d.ts +0 -1
- package/lib/orm/index.js +7 -6
- package/lib/orm-core/callback.js +1 -0
- package/lib/orm-core/dialect.js +1 -0
- package/lib/orm-core/error.js +3 -3
- package/lib/orm-core/index.js +1 -0
- package/lib/orm-core/sync.js +1 -0
- package/lib/orm-core/utils.js +1 -0
- package/lib/orm-property/Property.js +1 -0
- package/lib/orm-property/Utils.js +2 -2
- package/lib/orm-property/customTypes.js +2 -2
- package/lib/orm-property/index.js +3 -2
- package/lib/orm-property/transformer.js +2 -2
- package/lib/orm-property/transformers/dm.js +1 -0
- package/lib/orm-property/transformers/index.js +1 -0
- package/lib/orm-property/transformers/mysql.d.ts +0 -1
- package/lib/orm-property/transformers/mysql.js +1 -0
- package/lib/orm-property/transformers/postgresql.js +1 -0
- package/lib/orm-property/transformers/sqlite.js +1 -0
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/dm.js +1 -0
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/index.js +1 -0
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/mysql.js +1 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/postgresql.js +1 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/sqlite.js +1 -0
- package/lib/sql-ddl-sync/SQL.js +11 -11
- package/lib/sql-ddl-sync/Typo/Collection.js +1 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.js +1 -0
- package/lib/sql-ddl-sync/Typo/Dialect.js +1 -0
- package/lib/sql-ddl-sync/Typo/Driver.js +1 -0
- package/lib/sql-ddl-sync/Typo/Query.js +1 -0
- package/lib/sql-ddl-sync/Typo/SQL.js +1 -0
- package/lib/sql-ddl-sync/Typo/_common.js +1 -0
- package/lib/sql-ddl-sync/Utils.d.ts +0 -1
- package/lib/sql-ddl-sync/Utils.js +14 -14
- package/lib/sql-ddl-sync/index.js +3 -2
- package/lib/sql-query/Comparators.js +1 -0
- package/lib/sql-query/Create.js +1 -0
- package/lib/sql-query/Dialects/dm.js +1 -0
- package/lib/sql-query/Dialects/index.js +1 -0
- package/lib/sql-query/Dialects/mssql.js +1 -0
- package/lib/sql-query/Dialects/mysql.js +1 -0
- package/lib/sql-query/Dialects/postgresql.js +1 -0
- package/lib/sql-query/Dialects/sqlite.js +1 -0
- package/lib/sql-query/Helpers.d.ts +0 -1
- package/lib/sql-query/Helpers.js +21 -20
- package/lib/sql-query/Insert.js +1 -0
- package/lib/sql-query/Query.d.ts +0 -1
- package/lib/sql-query/Query.js +1 -0
- package/lib/sql-query/Remove.js +1 -0
- package/lib/sql-query/Select.js +1 -0
- package/lib/sql-query/Set.js +2 -2
- package/lib/sql-query/Typo/Aggregation.js +1 -0
- package/lib/sql-query/Typo/Comparators.js +1 -0
- package/lib/sql-query/Typo/Dialect.js +1 -0
- package/lib/sql-query/Typo/Field.js +1 -0
- package/lib/sql-query/Typo/Helper.js +1 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.js +1 -0
- package/lib/sql-query/Typo/Query.js +2 -1
- package/lib/sql-query/Typo/Sql.js +1 -0
- package/lib/sql-query/Typo/SubQuery.js +1 -0
- package/lib/sql-query/Typo/index.js +1 -0
- package/lib/sql-query/Update.js +1 -0
- package/lib/sql-query/Where.js +2 -2
- package/package.json +9 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (cli: import("@
|
|
1
|
+
declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (cli: import("@
|
|
1
|
+
declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const cmd: (cli: import("@
|
|
1
|
+
declare const cmd: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
|
|
2
2
|
export default cmd;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (cli: import("@
|
|
1
|
+
declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (cli: import("@
|
|
1
|
+
declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
|
|
2
2
|
export default _default;
|
package/lib/cli/helpers/ddl.d.ts
CHANGED
package/lib/cli/helpers/ddl.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.getAllTableNames = getAllTableNames;
|
|
4
|
+
exports.getTableDDLs = getTableDDLs;
|
|
3
5
|
const coroutine = require("coroutine");
|
|
4
6
|
function getAllTableNames(driver) {
|
|
5
7
|
let tableNames = [];
|
|
@@ -38,7 +40,6 @@ function getAllTableNames(driver) {
|
|
|
38
40
|
}
|
|
39
41
|
return tableNames;
|
|
40
42
|
}
|
|
41
|
-
exports.getAllTableNames = getAllTableNames;
|
|
42
43
|
function getTableDDLs(sync, { tableNames, afterGetTableDDL } = {}) {
|
|
43
44
|
tableNames = (tableNames === null || tableNames === void 0 ? void 0 : tableNames.length) ? tableNames : getAllTableNames(sync.dbdriver);
|
|
44
45
|
const tableDDLs = coroutine.parallel(tableNames, (tableName) => {
|
|
@@ -52,4 +53,3 @@ function getTableDDLs(sync, { tableNames, afterGetTableDDL } = {}) {
|
|
|
52
53
|
});
|
|
53
54
|
return tableDDLs;
|
|
54
55
|
}
|
|
55
|
-
exports.getTableDDLs = getTableDDLs;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.parsePkgInfo = parsePkgInfo;
|
|
4
|
+
exports.getPackgageNpmInfo = getPackgageNpmInfo;
|
|
5
|
+
exports.checkUpgrade = checkUpgrade;
|
|
3
6
|
const fs = require("fs");
|
|
4
7
|
const path = require("path");
|
|
5
8
|
const http = require("http");
|
|
@@ -10,13 +13,11 @@ const PKGJSON_FILE = path.resolve(__dirname, '../../package.json');
|
|
|
10
13
|
function parsePkgInfo(filepath = PKGJSON_FILE) {
|
|
11
14
|
return JSON.parse(fs.readFile(filepath).toString());
|
|
12
15
|
}
|
|
13
|
-
exports.parsePkgInfo = parsePkgInfo;
|
|
14
16
|
const PKGJSON = parsePkgInfo();
|
|
15
17
|
function getPackgageNpmInfo({ registry = 'https://registry.npmjs.org', pkgName = PKGJSON.name } = {}) {
|
|
16
18
|
const pkgInfo = parsePkgInfo();
|
|
17
19
|
return http.get(`${registry}/${pkgName}`, {});
|
|
18
20
|
}
|
|
19
|
-
exports.getPackgageNpmInfo = getPackgageNpmInfo;
|
|
20
21
|
function checkUpgrade({ pkgCurrentVersion }) {
|
|
21
22
|
var _a, _b, _c;
|
|
22
23
|
const response = getPackgageNpmInfo();
|
|
@@ -53,4 +54,3 @@ function checkUpgrade({ pkgCurrentVersion }) {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
exports.checkUpgrade = checkUpgrade;
|
package/lib/cli/index.js
CHANGED
package/lib/db-driver/Typo.d.ts
CHANGED
package/lib/db-driver/Typo.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/// <reference types="@fibjs/types" />
|
|
2
|
-
/// <reference types="@fibjs/types" />
|
|
3
|
-
/// <reference types="@fibjs/types" />
|
|
4
|
-
/// <reference types="@fibjs/types" />
|
|
5
|
-
/// <reference types="@fibjs/types" />
|
|
6
1
|
import { FxDbDriverNS } from '../Typo';
|
|
7
2
|
import { FxOrmCoreCallbackNS } from '../../orm-core/index';
|
|
8
3
|
declare function getDriver(name: 'mysql'): typeof import('./driver-mysql').default;
|
package/lib/db-driver/index.js
CHANGED
package/lib/db-driver/utils.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/// <reference types="@fibjs/types" />
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.driverUUid = driverUUid;
|
|
5
|
+
exports.filterDriverType = filterDriverType;
|
|
6
|
+
exports.forceInteger = forceInteger;
|
|
7
|
+
exports.castQueryStringToBoolean = castQueryStringToBoolean;
|
|
8
|
+
exports.ensureSuffix = ensureSuffix;
|
|
9
|
+
exports.parseConnectionString = parseConnectionString;
|
|
10
|
+
exports.arraify = arraify;
|
|
11
|
+
exports.logDebugSQL = logDebugSQL;
|
|
12
|
+
exports.detectWindowsCodePoints = detectWindowsCodePoints;
|
|
13
|
+
exports.filterPSQLSearchPath = filterPSQLSearchPath;
|
|
4
14
|
const url = require("url");
|
|
5
15
|
const util = require("util");
|
|
6
16
|
const tty = require("tty");
|
|
@@ -12,7 +22,6 @@ const ParseQSDotKey = require("parse-querystring-dotkey");
|
|
|
12
22
|
function driverUUid() {
|
|
13
23
|
return uuid.node().hex();
|
|
14
24
|
}
|
|
15
|
-
exports.driverUUid = driverUUid;
|
|
16
25
|
function filterDriverType(protocol) {
|
|
17
26
|
switch (protocol) {
|
|
18
27
|
case 'sqlite:':
|
|
@@ -34,7 +43,6 @@ function filterDriverType(protocol) {
|
|
|
34
43
|
return 'unknown';
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
|
-
exports.filterDriverType = filterDriverType;
|
|
38
46
|
function forceInteger(input, fallback) {
|
|
39
47
|
try {
|
|
40
48
|
input = parseInt(input);
|
|
@@ -46,7 +54,6 @@ function forceInteger(input, fallback) {
|
|
|
46
54
|
input = fallback;
|
|
47
55
|
return input;
|
|
48
56
|
}
|
|
49
|
-
exports.forceInteger = forceInteger;
|
|
50
57
|
function castQueryStringToBoolean(input) {
|
|
51
58
|
switch (input) {
|
|
52
59
|
case "1":
|
|
@@ -63,7 +70,6 @@ function castQueryStringToBoolean(input) {
|
|
|
63
70
|
return !!input;
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
|
-
exports.castQueryStringToBoolean = castQueryStringToBoolean;
|
|
67
73
|
function unPrefix(str = '', prefix = '/') {
|
|
68
74
|
if (!str || typeof str !== 'string')
|
|
69
75
|
return '';
|
|
@@ -79,7 +85,6 @@ function ensureSuffix(str = '', suffix = '//') {
|
|
|
79
85
|
str += suffix;
|
|
80
86
|
return str;
|
|
81
87
|
}
|
|
82
|
-
exports.ensureSuffix = ensureSuffix;
|
|
83
88
|
function parseConnectionString(input) {
|
|
84
89
|
input = input || {};
|
|
85
90
|
let urlObj = input instanceof net.Url ? input : null;
|
|
@@ -135,16 +140,14 @@ function parseConnectionString(input) {
|
|
|
135
140
|
input.port = forceInteger(input.port, null);
|
|
136
141
|
return input;
|
|
137
142
|
}
|
|
138
|
-
exports.parseConnectionString = parseConnectionString;
|
|
139
143
|
function arraify(item) {
|
|
140
144
|
return Array.isArray(item) ? item : [item];
|
|
141
145
|
}
|
|
142
|
-
exports.arraify = arraify;
|
|
143
146
|
function logDebugSQL(dbtype, sql, is_sync = true) {
|
|
144
147
|
let fmt;
|
|
145
148
|
if (tty.isatty(process.stdout.fd)) {
|
|
146
|
-
fmt = "\
|
|
147
|
-
sql = sql.replace(/`(.+?)`/g, function (m) { return "\
|
|
149
|
+
fmt = "\x1b[32;1m(orm/%s) \x1b[34m%s\x1b[0m\n";
|
|
150
|
+
sql = sql.replace(/`(.+?)`/g, function (m) { return "\x1b[31m" + m + "\x1b[34m"; });
|
|
148
151
|
}
|
|
149
152
|
else {
|
|
150
153
|
fmt = "[SQL/%s] %s\n";
|
|
@@ -157,7 +160,6 @@ function logDebugSQL(dbtype, sql, is_sync = true) {
|
|
|
157
160
|
process.stdout.write(text);
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
exports.logDebugSQL = logDebugSQL;
|
|
161
163
|
;
|
|
162
164
|
function detectWindowsCodePoints() {
|
|
163
165
|
let codepoints = '';
|
|
@@ -178,10 +180,8 @@ function detectWindowsCodePoints() {
|
|
|
178
180
|
codepoints
|
|
179
181
|
};
|
|
180
182
|
}
|
|
181
|
-
exports.detectWindowsCodePoints = detectWindowsCodePoints;
|
|
182
183
|
function filterPSQLSearchPath(input_sp) {
|
|
183
184
|
input_sp = Array.isArray(input_sp) ? input_sp.join(', ') : `${input_sp}`;
|
|
184
185
|
const filtered_sp = input_sp === null || input_sp === void 0 ? void 0 : input_sp.replace(/[^a-zA-Z0-9_"$,]/g, '');
|
|
185
186
|
return filtered_sp || '';
|
|
186
187
|
}
|
|
187
|
-
exports.filterPSQLSearchPath = filterPSQLSearchPath;
|
package/lib/knex/knex.js
CHANGED
package/lib/knex/sandbox.js
CHANGED
package/lib/orm/Adapters.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.addAdapter = addAdapter;
|
|
4
|
+
exports.getAdapter = getAdapter;
|
|
3
5
|
const DMLs = require("./Drivers/DML");
|
|
4
6
|
const adapters = {};
|
|
5
7
|
function addAdapter(name, constructor) {
|
|
@@ -13,7 +15,6 @@ function addAdapter(name, constructor) {
|
|
|
13
15
|
configurable: false
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
|
-
exports.addAdapter = addAdapter;
|
|
17
18
|
addAdapter('mysql', DMLs.mysql.Driver);
|
|
18
19
|
addAdapter('sqlite', DMLs.sqlite.Driver);
|
|
19
20
|
addAdapter('postgres', DMLs.postgres.Driver);
|
|
@@ -41,4 +42,3 @@ function getAdapter(name) {
|
|
|
41
42
|
}
|
|
42
43
|
return adapters[name];
|
|
43
44
|
}
|
|
44
|
-
exports.getAdapter = getAdapter;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.prepare = prepare;
|
|
4
|
+
exports.extend = extend;
|
|
5
|
+
exports.autoFetch = autoFetch;
|
|
3
6
|
const util = require("util");
|
|
4
7
|
const Hook = require("../Hook");
|
|
5
8
|
const _cloneDeep = require("lodash.clonedeep");
|
|
@@ -117,14 +120,12 @@ function prepare(Model, assocs, opts) {
|
|
|
117
120
|
return association.model;
|
|
118
121
|
};
|
|
119
122
|
}
|
|
120
|
-
exports.prepare = prepare;
|
|
121
123
|
;
|
|
122
124
|
function extend(Model, Instance, Driver, associations, cfg) {
|
|
123
125
|
for (let i = 0; i < associations.length; i++) {
|
|
124
126
|
extendInstance(Model, Instance, Driver, associations[i], cfg);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
|
-
exports.extend = extend;
|
|
128
129
|
;
|
|
129
130
|
function autoFetch(Instance, associations, opts, parallel = false) {
|
|
130
131
|
if (associations.length === 0) {
|
|
@@ -132,7 +133,6 @@ function autoFetch(Instance, associations, opts, parallel = false) {
|
|
|
132
133
|
}
|
|
133
134
|
Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
|
|
134
135
|
}
|
|
135
|
-
exports.autoFetch = autoFetch;
|
|
136
136
|
;
|
|
137
137
|
function extendInstance(Model, Instance, Driver, association, cfg) {
|
|
138
138
|
Utilities.addHiddenPropertyToInstance(Instance, association.hasSyncAccessor, function () {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/// <reference lib="es5" />
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.prepare = prepare;
|
|
5
|
+
exports.extend = extend;
|
|
6
|
+
exports.autoFetch = autoFetch;
|
|
4
7
|
const util = require("util");
|
|
5
8
|
const _flatten = require("lodash.flatten");
|
|
6
9
|
const Hook = require("../Hook");
|
|
@@ -181,21 +184,18 @@ function prepare(Model, assocs, opts) {
|
|
|
181
184
|
return this;
|
|
182
185
|
};
|
|
183
186
|
}
|
|
184
|
-
exports.prepare = prepare;
|
|
185
187
|
;
|
|
186
188
|
function extend(Model, Instance, Driver, associations, cfg) {
|
|
187
189
|
for (let i = 0; i < associations.length; i++) {
|
|
188
190
|
extendInstance(Model, Instance, Driver, associations[i], cfg);
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
|
-
exports.extend = extend;
|
|
192
193
|
;
|
|
193
194
|
function autoFetch(Instance, associations, opts, parallel = false) {
|
|
194
195
|
if (associations.length === 0)
|
|
195
196
|
return;
|
|
196
197
|
Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
|
|
197
198
|
}
|
|
198
|
-
exports.autoFetch = autoFetch;
|
|
199
199
|
;
|
|
200
200
|
function adjustForMapsTo(properties, field) {
|
|
201
201
|
if (!field)
|
|
@@ -234,7 +234,7 @@ function extendInstance(Model, Instance, Driver, association, cfg) {
|
|
|
234
234
|
options.autoFetchLimit = 0;
|
|
235
235
|
options.__merge = {
|
|
236
236
|
from: { table: association.mergeTable, field: Object.keys(association.mergeAssocId) },
|
|
237
|
-
to: { table: association.model.table, field: association.model.id.slice(0) },
|
|
237
|
+
to: { table: association.model.table, field: association.model.id.slice(0) }, // clone model id
|
|
238
238
|
where: [association.mergeTable, join_conditions],
|
|
239
239
|
table: association.model.table,
|
|
240
240
|
select: []
|
|
@@ -318,7 +318,7 @@ function extendInstance(Model, Instance, Driver, association, cfg) {
|
|
|
318
318
|
extraWhere = Object.assign(Object.assign({}, options.join_where), extraWhere);
|
|
319
319
|
options.__merge = {
|
|
320
320
|
from: { table: association.mergeTable, field: Object.keys(association.mergeAssocId) },
|
|
321
|
-
to: { table: association.model.table, field: association.model.id.slice(0) },
|
|
321
|
+
to: { table: association.model.table, field: association.model.id.slice(0) }, // clone model id
|
|
322
322
|
where: [association.mergeTable, extraWhere],
|
|
323
323
|
table: association.model.table,
|
|
324
324
|
select: []
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.prepare = prepare;
|
|
4
|
+
exports.extend = extend;
|
|
5
|
+
exports.autoFetch = autoFetch;
|
|
3
6
|
const util = require("util");
|
|
4
7
|
const Hook = require("../Hook");
|
|
5
8
|
const Utilities = require("../Utilities");
|
|
@@ -112,7 +115,6 @@ function prepare(Model, assocs, opts) {
|
|
|
112
115
|
return this;
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
|
-
exports.prepare = prepare;
|
|
116
118
|
;
|
|
117
119
|
function extend(Model, Instance, Driver,
|
|
118
120
|
// extend target
|
|
@@ -121,14 +123,12 @@ associations, cfg) {
|
|
|
121
123
|
extendInstance(Model, Instance, Driver, associations[i], cfg);
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
|
-
exports.extend = extend;
|
|
125
126
|
;
|
|
126
127
|
function autoFetch(Instance, associations, opts, parallel) {
|
|
127
128
|
if (associations.length === 0)
|
|
128
129
|
return;
|
|
129
130
|
Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
|
|
130
131
|
}
|
|
131
|
-
exports.autoFetch = autoFetch;
|
|
132
132
|
;
|
|
133
133
|
function extendInstance(Model, Instance, Driver,
|
|
134
134
|
// extend target
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/// <reference lib="es6" />
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.ACCESSOR_KEYS = void 0;
|
|
5
|
+
exports.defineDefaultExtendsToTableName = defineDefaultExtendsToTableName;
|
|
6
|
+
exports.defineAssociationAccessorMethodName = defineAssociationAccessorMethodName;
|
|
7
|
+
exports.getMapsToFromProperty = getMapsToFromProperty;
|
|
8
|
+
exports.getMapsToFromPropertyHash = getMapsToFromPropertyHash;
|
|
9
|
+
exports.cutOffAssociatedModelFindOptions = cutOffAssociatedModelFindOptions;
|
|
10
|
+
exports.addAssociationInfoToModel = addAssociationInfoToModel;
|
|
4
11
|
function defineDefaultExtendsToTableName(modelTableName, assocName) {
|
|
5
12
|
return `${modelTableName}_${assocName}`;
|
|
6
13
|
}
|
|
7
|
-
exports.defineDefaultExtendsToTableName = defineDefaultExtendsToTableName;
|
|
8
14
|
function defineAssociationAccessorMethodName(prefixer, assocName) {
|
|
9
15
|
return `${prefixer}${assocName}`;
|
|
10
16
|
}
|
|
11
|
-
exports.defineAssociationAccessorMethodName = defineAssociationAccessorMethodName;
|
|
12
17
|
exports.ACCESSOR_KEYS = {
|
|
13
18
|
/* common :start */
|
|
14
19
|
"get": "get",
|
|
@@ -23,14 +28,12 @@ exports.ACCESSOR_KEYS = {
|
|
|
23
28
|
function getMapsToFromProperty(property, k) {
|
|
24
29
|
return property.mapsTo || k;
|
|
25
30
|
}
|
|
26
|
-
exports.getMapsToFromProperty = getMapsToFromProperty;
|
|
27
31
|
function getMapsToFromPropertyHash(hash) {
|
|
28
32
|
return Object.keys(hash).map(k => {
|
|
29
33
|
const item = hash[k];
|
|
30
34
|
return item.mapsTo || k;
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
|
-
exports.getMapsToFromPropertyHash = getMapsToFromPropertyHash;
|
|
34
37
|
function cutOffAssociatedModelFindOptions(findby_options, association_name) {
|
|
35
38
|
let opts = null;
|
|
36
39
|
const k = `find_options:${association_name}`;
|
|
@@ -41,7 +44,6 @@ function cutOffAssociatedModelFindOptions(findby_options, association_name) {
|
|
|
41
44
|
return;
|
|
42
45
|
return opts;
|
|
43
46
|
}
|
|
44
|
-
exports.cutOffAssociatedModelFindOptions = cutOffAssociatedModelFindOptions;
|
|
45
47
|
function addAssociationInfoToModel(Model, association_name, opts) {
|
|
46
48
|
Model.associations[association_name] = {
|
|
47
49
|
type: opts.type,
|
|
@@ -49,4 +51,3 @@ function addAssociationInfoToModel(Model, association_name, opts) {
|
|
|
49
51
|
};
|
|
50
52
|
return Model.associations[association_name];
|
|
51
53
|
}
|
|
52
|
-
exports.addAssociationInfoToModel = addAssociationInfoToModel;
|
package/lib/orm/ChainFind.js
CHANGED
package/lib/orm/ChainInstance.js
CHANGED
package/lib/orm/Debug.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.sql =
|
|
3
|
+
exports.sql = sql;
|
|
3
4
|
const util = require("util");
|
|
4
5
|
const tty = require("tty");
|
|
5
6
|
function sql(driver, sql) {
|
|
6
7
|
var fmt;
|
|
7
8
|
if (tty.isatty(process.stdout.fd)) {
|
|
8
|
-
fmt = "\
|
|
9
|
-
sql = sql.replace(/`(.+?)`/g, function (m) { return "\
|
|
9
|
+
fmt = "\x1b[32;1m(orm/%s) \x1b[34m%s\x1b[0m\n";
|
|
10
|
+
sql = sql.replace(/`(.+?)`/g, function (m) { return "\x1b[31m" + m + "\x1b[34m"; });
|
|
10
11
|
}
|
|
11
12
|
else {
|
|
12
13
|
fmt = "[SQL/%s] %s\n";
|
|
13
14
|
}
|
|
14
15
|
process.stdout.write(util.format(fmt, driver, sql));
|
|
15
16
|
}
|
|
16
|
-
exports.sql = sql;
|
|
17
17
|
;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="@fibjs/types" />
|
|
2
|
-
/// <reference types="@fibjs/types" />
|
|
3
1
|
import type { FxOrmCommon } from '../../Typo/_common';
|
|
4
2
|
import type { FxOrmDb } from '../../Typo/Db';
|
|
5
3
|
declare const Driver: typeof import("../../../db-driver/built-ins/driver-dm").default;
|
package/lib/orm/Drivers/DB/dm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="@fibjs/types" />
|
|
2
|
-
/// <reference types="@fibjs/types" />
|
|
3
1
|
import type { FxOrmCommon } from '../../Typo/_common';
|
|
4
2
|
import type { FxOrmDb } from '../../Typo/Db';
|
|
5
3
|
declare const Driver: typeof import("../../../db-driver/built-ins/driver-mysql").default;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="@fibjs/types" />
|
|
2
|
-
/// <reference types="@fibjs/types" />
|
|
3
1
|
import type { FxOrmCommon } from '../../Typo/_common';
|
|
4
2
|
import type { FxOrmDb } from '../../Typo/Db';
|
|
5
3
|
declare const Driver: typeof import("../../../db-driver/built-ins/driver-postgresql").default;
|