orchid-orm 1.5.8 → 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/dist/index.mjs CHANGED
@@ -1,51 +1,57 @@
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
+ 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(options.columnTypes, fn);
17
+ const shape = getColumnTypes(columnTypes2, fn);
12
18
  return {
13
19
  shape,
14
20
  type: void 0
15
21
  };
16
22
  };
17
- this.columnTypes = options.columnTypes;
23
+ this.columnTypes = columnTypes2;
18
24
  }
19
- belongsTo(fn, options2) {
25
+ belongsTo(fn, options) {
20
26
  return {
21
27
  type: "belongsTo",
22
28
  returns: "one",
23
29
  fn,
24
- options: options2
30
+ options
25
31
  };
26
32
  }
27
- hasOne(fn, options2) {
33
+ hasOne(fn, options) {
28
34
  return {
29
35
  type: "hasOne",
30
36
  returns: "one",
31
37
  fn,
32
- options: options2
38
+ options
33
39
  };
34
40
  }
35
- hasMany(fn, options2) {
41
+ hasMany(fn, options) {
36
42
  return {
37
43
  type: "hasMany",
38
44
  returns: "many",
39
45
  fn,
40
- options: options2
46
+ options
41
47
  };
42
48
  }
43
- hasAndBelongsToMany(fn, options2) {
49
+ hasAndBelongsToMany(fn, options) {
44
50
  return {
45
51
  type: "hasAndBelongsToMany",
46
52
  returns: "many",
47
53
  fn,
48
- options: options2
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"