vona-module-a-orm 5.0.56 → 5.0.57

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.
@@ -1,5 +1,5 @@
1
1
  import type { ServiceDb } from '../../service/db_.ts';
2
- import type { IDatabaseClientRecord, IDecoratorModelOptions, IModelClassRecord, IModelMethodOptionsGeneral, IModelUpdateOptionsGeneral, ITableRecord, TypeEntityMeta, TypeModelClassLike, TypeModelRelationOptionsMetaClient } from '../../types/index.ts';
2
+ import type { IDatabaseClientRecord, IDecoratorModelOptions, IModelClassRecord, IModelMethodOptionsGeneral, IModelUpdateOptionsGeneral, ITableRecord, TypeEntityMeta, TypeModelClassLike, TypeModelOptionsTable, TypeModelRelationOptionsMetaClient } from '../../types/index.ts';
3
3
  import type { BeanModel } from '../bean.model.ts';
4
4
  import { BeanBase } from 'vona';
5
5
  import { SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyModelOptions } from '../../types/index.ts';
@@ -11,7 +11,7 @@ export declare class BeanModelMeta<TRecord extends {} = {}> extends BeanBase {
11
11
  [SymbolKeyModelOptions]: IDecoratorModelOptions;
12
12
  private [SymbolModelDb]?;
13
13
  private [SymbolModelTable]?;
14
- protected __init__(clientName?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): void;
14
+ protected __init__(clientName?: keyof IDatabaseClientRecord | ServiceDb, table?: TypeModelOptionsTable): void;
15
15
  protected get self(): BeanModel<any>;
16
16
  protected get connection(): import("knex").Knex<any, any[]>;
17
17
  protected get dialect(): import("vona-module-a-orm").BeanDatabaseDialectBase;
@@ -19,7 +19,7 @@ export declare class BeanModelMeta<TRecord extends {} = {}> extends BeanBase {
19
19
  get modelViewRecord(): import("vona-module-a-version").ModelViewRecord;
20
20
  get db(): ServiceDb;
21
21
  private _getDb;
22
- getTable(): keyof ITableRecord;
22
+ getTable(where: object | undefined): keyof ITableRecord;
23
23
  private _getTable;
24
24
  get options(): IDecoratorModelOptions;
25
25
  get disableInstance(): boolean;
@@ -34,7 +34,7 @@ export declare class BeanModelMeta<TRecord extends {} = {}> extends BeanBase {
34
34
  protected _checkDisableDeletedByOptions(options?: IModelMethodOptionsGeneral): boolean;
35
35
  protected _checkDisableCreateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
36
36
  protected _checkDisableUpdateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
37
- newInstance(client?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): this;
38
- newInstanceTarget<MODEL extends BeanModelMeta | (keyof IModelClassRecord)>(modelClassTarget: TypeModelClassLike<MODEL>, client?: TypeModelRelationOptionsMetaClient, table?: keyof ITableRecord): BeanModelMeta;
37
+ newInstance(client?: keyof IDatabaseClientRecord | ServiceDb, table?: TypeModelOptionsTable): this;
38
+ newInstanceTarget<MODEL extends BeanModelMeta | (keyof IModelClassRecord)>(modelClassTarget: TypeModelClassLike<MODEL>, client?: TypeModelRelationOptionsMetaClient, table?: TypeModelOptionsTable): BeanModelMeta;
39
39
  }
40
40
  export {};
@@ -5,7 +5,7 @@ import { BeanQueueBase } from 'vona-module-a-queue';
5
5
  export interface TypeQueueDoubleDeleteJobData {
6
6
  beanFullName: string;
7
7
  clientName: keyof IDatabaseClientRecord;
8
- table: keyof ITableRecord;
8
+ table?: keyof ITableRecord;
9
9
  method: 'cacheEntityDelInner' | 'cacheEntityClearInner' | 'cacheQueryClearInner';
10
10
  args: any[];
11
11
  }
package/dist/index.js CHANGED
@@ -1406,15 +1406,15 @@ class BeanModelMeta extends BeanBase {
1406
1406
  // db
1407
1407
  return this.bean.database.getDb(clientName);
1408
1408
  }
1409
- getTable() {
1410
- return this[SymbolModelTable] ?? this._getTable();
1409
+ getTable(where) {
1410
+ return this._getTable(where);
1411
1411
  }
1412
- _getTable() {
1413
- const table = this.options.table;
1412
+ _getTable(where) {
1413
+ const table = this[SymbolModelTable] ?? this.options.table;
1414
1414
  if (table && typeof table === 'string') return table;
1415
1415
  const defaultTable = this.options.entity && $tableName(this.options.entity);
1416
1416
  if (table && typeof table === 'function') {
1417
- return table(this.ctx, defaultTable, this);
1417
+ return table(this.ctx, where, defaultTable, this);
1418
1418
  }
1419
1419
  if (defaultTable) return defaultTable;
1420
1420
  throw new Error(`not found table of ${this.$beanFullName}`);
@@ -1494,6 +1494,7 @@ class BeanModelMeta extends BeanBase {
1494
1494
  const beanOptions = appResource.getBean(modelClass2);
1495
1495
  const beanFullName = beanOptions.beanFullName;
1496
1496
  const options = beanOptions?.options;
1497
+ // client
1497
1498
  if (isNil(client) || client === '_auto_') {
1498
1499
  client = options?.client ? '_initial_' : '_inherit_';
1499
1500
  }
@@ -1513,7 +1514,7 @@ class BeanModelUtils extends BeanModelMeta {
1513
1514
  table = undefined;
1514
1515
  }
1515
1516
  // table
1516
- table = table || this.getTable();
1517
+ table = table || this.getTable(item);
1517
1518
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1518
1519
  // item
1519
1520
  if (!item) return [{}, {}];
@@ -1539,11 +1540,11 @@ class BeanModelUtils extends BeanModelMeta {
1539
1540
  if (this.options.entity) {
1540
1541
  return $tableDefaults(this.options.entity);
1541
1542
  }
1542
- table = table || this.getTable();
1543
+ table = table || this.getTable(undefined);
1543
1544
  return await this.db.columns.defaultData(table);
1544
1545
  }
1545
1546
  async columns(table) {
1546
- table = table || this.getTable();
1547
+ table = table || this.getTable(undefined);
1547
1548
  return await this.db.columns.columns(table);
1548
1549
  }
1549
1550
  isRaw(raw) {
@@ -1658,7 +1659,7 @@ class BeanModelUtils extends BeanModelMeta {
1658
1659
  }
1659
1660
  prepareWhere(builder, table, where, options) {
1660
1661
  // table
1661
- table = table || this.getTable();
1662
+ table = table || this.getTable(where);
1662
1663
  if (!table) throw new Error('should specify the table name');
1663
1664
  // disableInstance/disableDeleted
1664
1665
  where = Object.assign({}, where);
@@ -1738,7 +1739,7 @@ class BeanModelKnex extends BeanModelUtils {
1738
1739
  }
1739
1740
  builder(table) {
1740
1741
  // table
1741
- table = table || this.getTable();
1742
+ table = table || this.getTable(undefined);
1742
1743
  if (table) {
1743
1744
  return this.connection(table);
1744
1745
  }
@@ -1750,7 +1751,7 @@ class BeanModelKnex extends BeanModelUtils {
1750
1751
  table = undefined;
1751
1752
  }
1752
1753
  // table
1753
- table = table || this.getTable();
1754
+ table = table || this.getTable(undefined);
1754
1755
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1755
1756
  // builder
1756
1757
  const builder = this.builder(table);
@@ -1911,7 +1912,7 @@ class BeanModelCrudInner extends BeanModelView {
1911
1912
  // with undefined
1912
1913
  async _mget_original(table, ids, options) {
1913
1914
  // table
1914
- table = table || this.getTable();
1915
+ table = table || this.getTable(undefined);
1915
1916
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1916
1917
  // ids maybe empty
1917
1918
  if (!ids || ids.length === 0) return [];
@@ -1940,7 +1941,7 @@ class BeanModelCrudInner extends BeanModelView {
1940
1941
  }
1941
1942
  async _select(table, params, options, builder) {
1942
1943
  // table
1943
- table = table || this.getTable();
1944
+ table = table || this.getTable(params?.where);
1944
1945
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1945
1946
  // builder
1946
1947
  builder = builder ?? this._select_buildParams(table, params, options);
@@ -1976,7 +1977,7 @@ class BeanModelCrudInner extends BeanModelView {
1976
1977
  }
1977
1978
  async _get(table, where, options) {
1978
1979
  // table
1979
- table = table || this.getTable();
1980
+ table = table || this.getTable(where);
1980
1981
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1981
1982
  // params
1982
1983
  const params = {
@@ -1994,7 +1995,7 @@ class BeanModelCrudInner extends BeanModelView {
1994
1995
  }
1995
1996
  async _count(table, params, options) {
1996
1997
  // table
1997
- table = table || this.getTable();
1998
+ table = table || this.getTable(params?.where);
1998
1999
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
1999
2000
  // params
2000
2001
  params = params || {};
@@ -2012,12 +2013,12 @@ class BeanModelCrudInner extends BeanModelView {
2012
2013
  return this.extractFirstNumber(res);
2013
2014
  }
2014
2015
  async _insertBulk(table, data, options) {
2015
- // table
2016
- table = table || this.getTable();
2017
- if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2018
2016
  // data
2019
2017
  data = data || {};
2020
2018
  const datasTemp = Array.isArray(data) ? data : [data];
2019
+ // table
2020
+ table = table || this.getTable(datasTemp[0]);
2021
+ if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2021
2022
  // options
2022
2023
  const datas = [];
2023
2024
  const datasOriginal = [];
@@ -2052,7 +2053,7 @@ class BeanModelCrudInner extends BeanModelView {
2052
2053
  }
2053
2054
  async _update(table, data, options) {
2054
2055
  // table
2055
- table = table || this.getTable();
2056
+ table = table || this.getTable(data);
2056
2057
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2057
2058
  // data
2058
2059
  [data] = await this.prepareData(table, data);
@@ -2085,7 +2086,7 @@ class BeanModelCrudInner extends BeanModelView {
2085
2086
  }
2086
2087
  async _delete(table, where, options) {
2087
2088
  // table
2088
- table = table || this.getTable();
2089
+ table = table || this.getTable(where);
2089
2090
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2090
2091
  // disableDeleted
2091
2092
  if (!this._checkDisableDeletedByOptions(options)) {
@@ -2225,13 +2226,13 @@ let ServiceCacheEntity = (_dec$d = Service(), _dec2$d = BeanInfo({
2225
2226
  }
2226
2227
  async clear(table) {
2227
2228
  if (!this.enabled) return;
2228
- table = table || this._model.getTable();
2229
+ table = table || this._model.getTable(undefined);
2229
2230
  const cache = this.getInstance(table);
2230
2231
  await cache.clear();
2231
2232
  }
2232
2233
  async del(id, table) {
2233
2234
  if (!this.enabled) return;
2234
- table = table || this._model.getTable();
2235
+ table = table || this._model.getTable(undefined);
2235
2236
  const cache = this.getInstance(table);
2236
2237
  if (Array.isArray(id)) {
2237
2238
  await cache.mdel(id);
@@ -2253,7 +2254,7 @@ let ServiceCacheQuery = (_dec$c = Service(), _dec2$c = BeanInfo({
2253
2254
  }
2254
2255
  async clear(table) {
2255
2256
  if (!this.enabled) return;
2256
- table = table || this._model.getTable();
2257
+ table = table || this._model.getTable(undefined);
2257
2258
  const cache = this.getInstance(table);
2258
2259
  await cache.clear();
2259
2260
  }
@@ -2368,7 +2369,6 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2368
2369
  options
2369
2370
  } = relationReal;
2370
2371
  const modelTarget = this.__getModelTarget(model, options?.meta);
2371
- const tableNameTarget = modelTarget.getTable();
2372
2372
  const optionsReal = Object.assign({}, options, {
2373
2373
  include: includeReal,
2374
2374
  with: withReal
@@ -2406,21 +2406,21 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2406
2406
  if (optionsReal.groups) {
2407
2407
  const options2 = deepExtend({}, optionsReal, {
2408
2408
  where: {
2409
- [`${tableNameTarget}.${key}`]: idFrom
2409
+ [key]: idFrom
2410
2410
  }
2411
2411
  });
2412
2412
  entity[relationName] = await modelTarget.group(options2, methodOptionsReal);
2413
2413
  } else if (optionsReal.aggrs) {
2414
2414
  const options2 = deepExtend({}, optionsReal, {
2415
2415
  where: {
2416
- [`${tableNameTarget}.${key}`]: idFrom
2416
+ [key]: idFrom
2417
2417
  }
2418
2418
  });
2419
2419
  entity[relationName] = await modelTarget.aggregate(options2, methodOptionsReal);
2420
2420
  } else {
2421
2421
  const options2 = deepExtend({}, optionsReal, {
2422
2422
  where: {
2423
- [`${tableNameTarget}.${key}`]: idFrom
2423
+ [key]: idFrom
2424
2424
  }
2425
2425
  });
2426
2426
  entity[relationName] = await modelTarget.select(options2, methodOptionsReal);
@@ -2441,14 +2441,14 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2441
2441
  if (optionsReal.groups) {
2442
2442
  const options2 = deepExtend({}, optionsReal, {
2443
2443
  where: {
2444
- [`${tableNameTarget}.id`]: idsTo
2444
+ id: idsTo
2445
2445
  }
2446
2446
  });
2447
2447
  entity[relationName] = await modelTarget.group(options2, methodOptionsReal);
2448
2448
  } else if (optionsReal.aggrs) {
2449
2449
  const options2 = deepExtend({}, optionsReal, {
2450
2450
  where: {
2451
- [`${tableNameTarget}.id`]: idsTo
2451
+ id: idsTo
2452
2452
  }
2453
2453
  });
2454
2454
  entity[relationName] = await modelTarget.aggregate(options2, methodOptionsReal);
@@ -2471,7 +2471,6 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2471
2471
  options
2472
2472
  } = relationReal;
2473
2473
  const modelTarget = this.__getModelTarget(model, options?.meta);
2474
- const tableNameTarget = modelTarget.getTable();
2475
2474
  const optionsReal = Object.assign({}, options, {
2476
2475
  include: includeReal,
2477
2476
  with: withReal
@@ -2513,11 +2512,11 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2513
2512
  } else if (type === 'hasMany') {
2514
2513
  const idsFrom = entities.map(item => cast(item).id).filter(id => !isNil(id));
2515
2514
  if (optionsReal.groups) {
2516
- const groups = [`${tableNameTarget}.${key}`].concat(optionsReal.groups);
2515
+ const groups = [key].concat(optionsReal.groups);
2517
2516
  const options2 = deepExtend({}, optionsReal, {
2518
2517
  groups,
2519
2518
  where: {
2520
- [`${tableNameTarget}.${key}`]: idsFrom
2519
+ [key]: idsFrom
2521
2520
  }
2522
2521
  });
2523
2522
  const items = await modelTarget.group(options2, methodOptionsReal);
@@ -2532,9 +2531,9 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2532
2531
  }
2533
2532
  } else if (optionsReal.aggrs) {
2534
2533
  const options2 = deepExtend({}, optionsReal, {
2535
- groups: `${tableNameTarget}.${key}`,
2534
+ groups: key,
2536
2535
  where: {
2537
- [`${tableNameTarget}.${key}`]: idsFrom
2536
+ [key]: idsFrom
2538
2537
  }
2539
2538
  });
2540
2539
  const items = await modelTarget.group(options2, methodOptionsReal);
@@ -2550,7 +2549,7 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2550
2549
  const options2 = deepExtend({}, optionsReal, {
2551
2550
  columns,
2552
2551
  where: {
2553
- [`${tableNameTarget}.${key}`]: idsFrom
2552
+ [key]: idsFrom
2554
2553
  }
2555
2554
  });
2556
2555
  const items = await modelTarget.select(options2, methodOptionsReal);
@@ -2583,7 +2582,7 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2583
2582
  const options2 = deepExtend({}, optionsReal, {
2584
2583
  groups: optionsReal.groups,
2585
2584
  where: {
2586
- [`${tableNameTarget}.id`]: idsTo
2585
+ id: idsTo
2587
2586
  }
2588
2587
  });
2589
2588
  entity[relationName] = await modelTarget.group(options2, methodOptionsReal);
@@ -2593,7 +2592,7 @@ let ServiceRelations = (_dec$b = Service(), _dec2$b = BeanInfo({
2593
2592
  const idsTo = itemsMiddle.filter(item => item[keyFrom] === cast(entity).id).map(item => item[keyTo]);
2594
2593
  const options2 = deepExtend({}, optionsReal, {
2595
2594
  where: {
2596
- [`${tableNameTarget}.id`]: idsTo
2595
+ id: idsTo
2597
2596
  }
2598
2597
  });
2599
2598
  entity[relationName] = await modelTarget.aggregate(options2, methodOptionsReal);
@@ -2900,7 +2899,7 @@ class BeanModelCache extends BeanModelCrud {
2900
2899
  async __insertBulk_raw(table, items, options) {
2901
2900
  if (items.length === 0) return [];
2902
2901
  // table
2903
- table = table || this.getTable();
2902
+ table = table || this.getTable(items[0]);
2904
2903
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2905
2904
  // insert
2906
2905
  const res = await this._insertBulk(table, items, options);
@@ -2918,7 +2917,7 @@ class BeanModelCache extends BeanModelCrud {
2918
2917
  }
2919
2918
  async __mutateBulk_raw(table, items, options) {
2920
2919
  // table
2921
- table = table || this.getTable();
2920
+ table = table || this.getTable(items[0]);
2922
2921
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2923
2922
  // check
2924
2923
  const indexesInsert = [];
@@ -2980,7 +2979,7 @@ class BeanModelCache extends BeanModelCrud {
2980
2979
  }
2981
2980
  async __mget_raw(table, ids, options) {
2982
2981
  // table
2983
- table = table || this.getTable();
2982
+ table = table || this.getTable(undefined);
2984
2983
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
2985
2984
  // check if cache
2986
2985
  if (this._checkDisableCacheEntityByOptions(options)) {
@@ -3021,7 +3020,7 @@ class BeanModelCache extends BeanModelCrud {
3021
3020
  }
3022
3021
  async __aggregate_raw(table, params, options) {
3023
3022
  // table
3024
- table = table || this.getTable();
3023
+ table = table || this.getTable(params?.where);
3025
3024
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3026
3025
  const items = await this.__select_cache(table, params, options);
3027
3026
  return this.convertItemsToBigNumber(items);
@@ -3031,7 +3030,7 @@ class BeanModelCache extends BeanModelCrud {
3031
3030
  }
3032
3031
  async __group_raw(table, params, options) {
3033
3032
  // table
3034
- table = table || this.getTable();
3033
+ table = table || this.getTable(params?.where);
3035
3034
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3036
3035
  const items = await this.__select_cache(table, params, options);
3037
3036
  return this.convertItemsToBigNumber(items);
@@ -3076,7 +3075,7 @@ class BeanModelCache extends BeanModelCrud {
3076
3075
  }
3077
3076
  async __select_raw(table, params, options) {
3078
3077
  // table
3079
- table = table || this.getTable();
3078
+ table = table || this.getTable(params?.where);
3080
3079
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3081
3080
  // check if cache
3082
3081
  if (this._checkDisableCacheEntityByOptions(options)) {
@@ -3144,7 +3143,7 @@ class BeanModelCache extends BeanModelCrud {
3144
3143
  }
3145
3144
  async __get_raw(table, where, options) {
3146
3145
  // table
3147
- table = table || this.getTable();
3146
+ table = table || this.getTable(where);
3148
3147
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3149
3148
  // check if cache
3150
3149
  if (this._checkDisableCacheEntityByOptions(options)) {
@@ -3199,7 +3198,7 @@ class BeanModelCache extends BeanModelCrud {
3199
3198
  }
3200
3199
  async __update_raw(table, data, options) {
3201
3200
  // table
3202
- table = table || this.getTable();
3201
+ table = table || this.getTable(data);
3203
3202
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3204
3203
  // check if cache
3205
3204
  if (this._checkDisableCacheEntityByOptions(options)) {
@@ -3277,7 +3276,7 @@ class BeanModelCache extends BeanModelCrud {
3277
3276
  }
3278
3277
  async __delete_raw(table, where, options) {
3279
3278
  // table
3280
- table = table || this.getTable();
3279
+ table = table || this.getTable(where);
3281
3280
  if (!table) return this.scopeOrm.error.ShouldSpecifyTable.throw();
3282
3281
  // check if cache
3283
3282
  if (this._checkDisableCacheEntityByOptions(options)) {
@@ -3361,7 +3360,7 @@ class BeanModelCache extends BeanModelCrud {
3361
3360
  this._shardingCacheDoubleDelete({
3362
3361
  beanFullName: this.$beanFullName,
3363
3362
  clientName: this.db.clientName,
3364
- table: this.getTable(),
3363
+ table,
3365
3364
  method: 'cacheEntityDelInner',
3366
3365
  args: [id, table]
3367
3366
  });
@@ -3380,7 +3379,7 @@ class BeanModelCache extends BeanModelCrud {
3380
3379
  this._shardingCacheDoubleDelete({
3381
3380
  beanFullName: this.$beanFullName,
3382
3381
  clientName: this.db.clientName,
3383
- table: this.getTable(),
3382
+ table,
3384
3383
  method: 'cacheEntityClearInner',
3385
3384
  args: [table]
3386
3385
  });
@@ -3399,7 +3398,7 @@ class BeanModelCache extends BeanModelCrud {
3399
3398
  this._shardingCacheDoubleDelete({
3400
3399
  beanFullName: this.$beanFullName,
3401
3400
  clientName: this.db.clientName,
3402
- table: this.getTable(),
3401
+ table,
3403
3402
  method: 'cacheQueryClearInner',
3404
3403
  args: [table]
3405
3404
  });
@@ -10,7 +10,7 @@ export interface IModelRecord {
10
10
  }
11
11
  export interface IModelClassRecord {
12
12
  }
13
- export type TypeDynamicTableName = (ctx: VonaContext, defaultTable: keyof ITableRecord, modelInstance: any) => string;
13
+ export type TypeDynamicTableName = (ctx: VonaContext, where: any | undefined, defaultTable: keyof ITableRecord, modelInstance: any) => string;
14
14
  export type TypeDynamicClientName = (ctx: VonaContext, modelInstance: any) => keyof IDatabaseClientRecord;
15
15
  export type TypeModelsClearedByFn = (ctx: VonaContext, modelTarget: any, modelSource: any) => Promise<void>;
16
16
  export type TypeSoftDeletionPruneHandler = (ctx: VonaContext, modelInstance: any, options: ISoftDeletionPruneHandlerOptions) => Promise<void>;
@@ -21,9 +21,10 @@ export interface ISoftDeletionPrune {
21
21
  handler?: TypeSoftDeletionPruneHandler;
22
22
  expired?: number;
23
23
  }
24
+ export type TypeModelOptionsTable = TypeDynamicTableName | keyof ITableRecord;
24
25
  export interface IDecoratorModelOptions<TRecord extends EntityBaseEmpty = any> {
25
26
  entity?: Constructable<TRecord>;
26
- table?: TypeDynamicTableName | keyof ITableRecord;
27
+ table?: TypeModelOptionsTable;
27
28
  disableDeleted?: boolean;
28
29
  disableInstance?: boolean;
29
30
  disableCreateTime?: boolean;
@@ -4,8 +4,7 @@ import type { IDatabaseClientRecord } from './database.ts';
4
4
  import type { TypeModelSelectAggrParamsAggrs } from './modelAggr.ts';
5
5
  import type { IBuildModelSelectGeneralParamsBasic } from './modelGeneral.ts';
6
6
  import type { TypeModelColumn, TypeModelColumnsPatch, TypeModelColumnsStrict } from './modelWhere.ts';
7
- import type { IModelClassRecord } from './onion/model.ts';
8
- import type { ITableRecord } from './onion/table.ts';
7
+ import type { IModelClassRecord, TypeModelOptionsTable } from './onion/model.ts';
9
8
  import type { TypeModelClassLike, TypeModelOfModelLike, TypeModelsClassLikeGeneral, TypeSymbolKeyEntity } from './relations.ts';
10
9
  import type { TypeEntityTableColumnNamesOfGeneral, TypeEntityTableColumnsOfGeneral } from './relationsColumns.ts';
11
10
  import type { TypeEntityTableNamesOfGeneral } from './relationsTables.ts';
@@ -48,7 +47,7 @@ export interface IBuildModelRelationOptionsMany<TRecord, AUTOLOAD extends boolea
48
47
  }
49
48
  export interface IModelRelationOptionsMetaBasic {
50
49
  client?: TypeModelRelationOptionsMetaClient;
51
- table?: keyof ITableRecord;
50
+ table?: TypeModelOptionsTable;
52
51
  }
53
52
  export interface IModelRelationOptionsMeta extends IModelRelationOptionsMetaBasic {
54
53
  middle?: IModelRelationOptionsMetaBasic;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-orm",
3
3
  "type": "module",
4
- "version": "5.0.56",
4
+ "version": "5.0.57",
5
5
  "title": "a-orm",
6
6
  "vonaModule": {
7
7
  "capabilities": {