orchid-orm 1.5.9 → 1.5.11
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +205 -7
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/codegen/createBaseTableFile.test.ts +1 -6
- package/src/codegen/createBaseTableFile.ts +1 -6
- package/src/index.ts +1 -0
- package/src/orm.test.ts +3 -9
- package/src/repo.test.ts +2 -2
- package/src/table.test.ts +6 -6
- package/src/table.ts +18 -5
- package/src/test-utils/test-tables.ts +5 -6
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,56 @@
|
|
|
1
|
-
import { getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape,
|
|
1
|
+
import { columnTypes, getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape, getClonedQueryData, singleQuote, columnsShapeToCode, codeToString, quoteObjectKey, primaryKeyToCode, indexToCode, foreignKeyToCode, columnIndexesToCode, columnForeignKeysToCode, addCode, columnDefaultArgumentToCode } from 'pqb';
|
|
2
|
+
export { columnTypes } from 'pqb';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import path__default from 'path';
|
|
4
5
|
import fs from 'fs/promises';
|
|
5
6
|
import typescript from 'typescript';
|
|
6
7
|
|
|
7
|
-
const createBaseTable = (options) => {
|
|
8
|
+
const createBaseTable = (options = { columnTypes }) => {
|
|
9
|
+
const ct = typeof options.columnTypes === "function" ? options.columnTypes(columnTypes) : options.columnTypes;
|
|
10
|
+
return create(ct);
|
|
11
|
+
};
|
|
12
|
+
const create = (columnTypes2) => {
|
|
8
13
|
return class BaseTable {
|
|
9
14
|
constructor() {
|
|
10
15
|
this.setColumns = (fn) => {
|
|
11
|
-
const shape = getColumnTypes(
|
|
16
|
+
const shape = getColumnTypes(columnTypes2, fn);
|
|
12
17
|
return {
|
|
13
18
|
shape,
|
|
14
19
|
type: void 0
|
|
15
20
|
};
|
|
16
21
|
};
|
|
17
|
-
this.columnTypes =
|
|
22
|
+
this.columnTypes = columnTypes2;
|
|
18
23
|
}
|
|
19
|
-
belongsTo(fn,
|
|
24
|
+
belongsTo(fn, options) {
|
|
20
25
|
return {
|
|
21
26
|
type: "belongsTo",
|
|
22
27
|
returns: "one",
|
|
23
28
|
fn,
|
|
24
|
-
options
|
|
29
|
+
options
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
|
-
hasOne(fn,
|
|
32
|
+
hasOne(fn, options) {
|
|
28
33
|
return {
|
|
29
34
|
type: "hasOne",
|
|
30
35
|
returns: "one",
|
|
31
36
|
fn,
|
|
32
|
-
options
|
|
37
|
+
options
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
|
-
hasMany(fn,
|
|
40
|
+
hasMany(fn, options) {
|
|
36
41
|
return {
|
|
37
42
|
type: "hasMany",
|
|
38
43
|
returns: "many",
|
|
39
44
|
fn,
|
|
40
|
-
options
|
|
45
|
+
options
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
|
-
hasAndBelongsToMany(fn,
|
|
48
|
+
hasAndBelongsToMany(fn, options) {
|
|
44
49
|
return {
|
|
45
50
|
type: "hasAndBelongsToMany",
|
|
46
51
|
returns: "many",
|
|
47
52
|
fn,
|
|
48
|
-
options
|
|
53
|
+
options
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
56
|
};
|
|
@@ -2264,13 +2269,8 @@ const createBaseTableFile = async ({
|
|
|
2264
2269
|
await fs.writeFile(
|
|
2265
2270
|
baseTablePath,
|
|
2266
2271
|
`import { createBaseTable } from 'orchid-orm';
|
|
2267
|
-
import { columnTypes } from 'pqb';
|
|
2268
2272
|
|
|
2269
|
-
export const ${baseTableName} = createBaseTable(
|
|
2270
|
-
columnTypes: {
|
|
2271
|
-
...columnTypes,
|
|
2272
|
-
},
|
|
2273
|
-
});
|
|
2273
|
+
export const ${baseTableName} = createBaseTable();
|
|
2274
2274
|
`,
|
|
2275
2275
|
{
|
|
2276
2276
|
flag: "wx"
|