orchid-orm 1.5.9 → 1.5.10
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 +8 -0
- package/dist/index.d.ts +204 -6
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -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 +1 -1
- package/src/table.ts +15 -5
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
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
|
+
return create(
|
|
10
|
+
options.columnTypes
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
const create = (columnTypes2) => {
|
|
8
14
|
return class BaseTable {
|
|
9
15
|
constructor() {
|
|
10
16
|
this.setColumns = (fn) => {
|
|
11
|
-
const shape = getColumnTypes(
|
|
17
|
+
const shape = getColumnTypes(columnTypes2, fn);
|
|
12
18
|
return {
|
|
13
19
|
shape,
|
|
14
20
|
type: void 0
|
|
15
21
|
};
|
|
16
22
|
};
|
|
17
|
-
this.columnTypes =
|
|
23
|
+
this.columnTypes = columnTypes2;
|
|
18
24
|
}
|
|
19
|
-
belongsTo(fn,
|
|
25
|
+
belongsTo(fn, options) {
|
|
20
26
|
return {
|
|
21
27
|
type: "belongsTo",
|
|
22
28
|
returns: "one",
|
|
23
29
|
fn,
|
|
24
|
-
options
|
|
30
|
+
options
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
|
-
hasOne(fn,
|
|
33
|
+
hasOne(fn, options) {
|
|
28
34
|
return {
|
|
29
35
|
type: "hasOne",
|
|
30
36
|
returns: "one",
|
|
31
37
|
fn,
|
|
32
|
-
options
|
|
38
|
+
options
|
|
33
39
|
};
|
|
34
40
|
}
|
|
35
|
-
hasMany(fn,
|
|
41
|
+
hasMany(fn, options) {
|
|
36
42
|
return {
|
|
37
43
|
type: "hasMany",
|
|
38
44
|
returns: "many",
|
|
39
45
|
fn,
|
|
40
|
-
options
|
|
46
|
+
options
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
|
-
hasAndBelongsToMany(fn,
|
|
49
|
+
hasAndBelongsToMany(fn, options) {
|
|
44
50
|
return {
|
|
45
51
|
type: "hasAndBelongsToMany",
|
|
46
52
|
returns: "many",
|
|
47
53
|
fn,
|
|
48
|
-
options
|
|
54
|
+
options
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
};
|
|
@@ -2264,13 +2270,8 @@ const createBaseTableFile = async ({
|
|
|
2264
2270
|
await fs.writeFile(
|
|
2265
2271
|
baseTablePath,
|
|
2266
2272
|
`import { createBaseTable } from 'orchid-orm';
|
|
2267
|
-
import { columnTypes } from 'pqb';
|
|
2268
2273
|
|
|
2269
|
-
export const ${baseTableName} = createBaseTable(
|
|
2270
|
-
columnTypes: {
|
|
2271
|
-
...columnTypes,
|
|
2272
|
-
},
|
|
2273
|
-
});
|
|
2274
|
+
export const ${baseTableName} = createBaseTable();
|
|
2274
2275
|
`,
|
|
2275
2276
|
{
|
|
2276
2277
|
flag: "wx"
|