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/dist/index.mjs CHANGED
@@ -1,51 +1,56 @@
1
- import { getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape, columnTypes, getClonedQueryData, singleQuote, columnsShapeToCode, codeToString, quoteObjectKey, primaryKeyToCode, indexToCode, foreignKeyToCode, columnIndexesToCode, columnForeignKeysToCode, addCode, columnDefaultArgumentToCode } from 'pqb';
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(options.columnTypes, fn);
16
+ const shape = getColumnTypes(columnTypes2, fn);
12
17
  return {
13
18
  shape,
14
19
  type: void 0
15
20
  };
16
21
  };
17
- this.columnTypes = options.columnTypes;
22
+ this.columnTypes = columnTypes2;
18
23
  }
19
- belongsTo(fn, options2) {
24
+ belongsTo(fn, options) {
20
25
  return {
21
26
  type: "belongsTo",
22
27
  returns: "one",
23
28
  fn,
24
- options: options2
29
+ options
25
30
  };
26
31
  }
27
- hasOne(fn, options2) {
32
+ hasOne(fn, options) {
28
33
  return {
29
34
  type: "hasOne",
30
35
  returns: "one",
31
36
  fn,
32
- options: options2
37
+ options
33
38
  };
34
39
  }
35
- hasMany(fn, options2) {
40
+ hasMany(fn, options) {
36
41
  return {
37
42
  type: "hasMany",
38
43
  returns: "many",
39
44
  fn,
40
- options: options2
45
+ options
41
46
  };
42
47
  }
43
- hasAndBelongsToMany(fn, options2) {
48
+ hasAndBelongsToMany(fn, options) {
44
49
  return {
45
50
  type: "hasAndBelongsToMany",
46
51
  returns: "many",
47
52
  fn,
48
- options: options2
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"