orchid-orm 1.15.2 → 1.16.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/dist/bin.js +8 -12
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +34 -36
- package/dist/index.js +18 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -4,39 +4,36 @@ import { getStackTrace, applyMixins, getCallerFilePath, snakeCaseKey, toSnakeCas
|
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
5
|
|
|
6
6
|
const createBaseTable = ({
|
|
7
|
-
columnTypes:
|
|
7
|
+
columnTypes: columnTypesArg,
|
|
8
8
|
snakeCase,
|
|
9
|
-
filePath,
|
|
9
|
+
filePath: filePathArg,
|
|
10
10
|
nowSQL,
|
|
11
|
-
exportAs,
|
|
12
|
-
language
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return create(
|
|
16
|
-
ct,
|
|
17
|
-
// stack is needed only if filePath wasn't given
|
|
18
|
-
filePath || getStackTrace(),
|
|
19
|
-
snakeCase,
|
|
20
|
-
nowSQL,
|
|
21
|
-
exportAs,
|
|
22
|
-
language
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "BaseTable", language) => {
|
|
11
|
+
exportAs = "BaseTable",
|
|
12
|
+
language,
|
|
13
|
+
schemaProvider: schemaProviderArg
|
|
14
|
+
} = {}) => {
|
|
26
15
|
var _a;
|
|
16
|
+
const columnTypes$1 = typeof columnTypesArg === "function" ? columnTypesArg(columnTypes) : columnTypesArg || columnTypes;
|
|
17
|
+
const filePathOrStack = filePathArg || getStackTrace();
|
|
27
18
|
let filePath;
|
|
19
|
+
function schemaProvider() {
|
|
20
|
+
const schema = schemaProviderArg.call(this);
|
|
21
|
+
this.schema = () => schema;
|
|
22
|
+
return schema;
|
|
23
|
+
}
|
|
28
24
|
const base = (_a = class {
|
|
29
25
|
constructor() {
|
|
30
26
|
this.snakeCase = snakeCase;
|
|
31
|
-
this.columnTypes = columnTypes;
|
|
27
|
+
this.columnTypes = columnTypes$1;
|
|
32
28
|
this.q = {};
|
|
33
29
|
this.language = language;
|
|
34
30
|
}
|
|
35
31
|
static getFilePath() {
|
|
36
32
|
if (filePath)
|
|
37
33
|
return filePath;
|
|
38
|
-
if (typeof filePathOrStack === "string")
|
|
34
|
+
if (typeof filePathOrStack === "string") {
|
|
39
35
|
return filePath = filePathOrStack;
|
|
36
|
+
}
|
|
40
37
|
filePath = getCallerFilePath(filePathOrStack);
|
|
41
38
|
if (filePath)
|
|
42
39
|
return filePath;
|
|
@@ -60,8 +57,8 @@ const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "Bas
|
|
|
60
57
|
);
|
|
61
58
|
}
|
|
62
59
|
setColumns(fn) {
|
|
63
|
-
columnTypes[snakeCaseKey] = this.snakeCase;
|
|
64
|
-
const shape = getColumnTypes(columnTypes, fn, nowSQL, this.language);
|
|
60
|
+
columnTypes$1[snakeCaseKey] = this.snakeCase;
|
|
61
|
+
const shape = getColumnTypes(columnTypes$1, fn, nowSQL, this.language);
|
|
65
62
|
if (this.snakeCase) {
|
|
66
63
|
for (const key in shape) {
|
|
67
64
|
const column = shape[key];
|
|
@@ -73,10 +70,7 @@ const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "Bas
|
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
|
-
return
|
|
77
|
-
shape,
|
|
78
|
-
type: void 0
|
|
79
|
-
};
|
|
73
|
+
return this.constructor.prototype.columns = shape;
|
|
80
74
|
}
|
|
81
75
|
belongsTo(fn, options) {
|
|
82
76
|
return {
|
|
@@ -106,9 +100,9 @@ const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "Bas
|
|
|
106
100
|
options
|
|
107
101
|
};
|
|
108
102
|
}
|
|
109
|
-
}, _a.nowSQL = nowSQL, _a.exportAs = exportAs, _a);
|
|
103
|
+
}, _a.nowSQL = nowSQL, _a.exportAs = exportAs, _a.schema = schemaProvider, _a);
|
|
110
104
|
applyMixins(base, [QueryHooks]);
|
|
111
|
-
base.prototype.columnTypes = columnTypes;
|
|
105
|
+
base.prototype.columnTypes = columnTypes$1;
|
|
112
106
|
return base;
|
|
113
107
|
};
|
|
114
108
|
|
|
@@ -1712,7 +1706,7 @@ const orchidORM = (_a, tables) => {
|
|
|
1712
1706
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1713
1707
|
qb,
|
|
1714
1708
|
table.table,
|
|
1715
|
-
table.columns
|
|
1709
|
+
table.columns,
|
|
1716
1710
|
table.columnTypes,
|
|
1717
1711
|
transactionStorage,
|
|
1718
1712
|
options2
|