vona-module-a-orm 5.0.46 → 5.0.47

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.
@@ -30,7 +30,7 @@ export declare class BeanModelMeta<TRecord extends {} = {}> extends BeanBase {
30
30
  protected _prepareDisableDeletedByOptions(table: keyof ITableRecord, data: any, options?: IModelMethodOptionsGeneral, useRaw?: boolean): any;
31
31
  protected _prepareDisableDeletedByOptionsSimple(options?: IModelMethodOptionsGeneral): boolean | undefined;
32
32
  protected _checkIfEntityValidByDeleted(entity: any, options?: IModelMethodOptionsGeneral): boolean;
33
- protected _checkDisableInstanceByOptions(options?: IModelMethodOptionsGeneral): boolean;
33
+ protected _checkDisableInstanceByOptions(_options?: IModelMethodOptionsGeneral): boolean;
34
34
  protected _checkDisableDeletedByOptions(options?: IModelMethodOptionsGeneral): boolean;
35
35
  protected _checkDisableCreateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
36
36
  protected _checkDisableUpdateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
@@ -35,11 +35,13 @@ export declare function config(_app: VonaApplication): {
35
35
  updateAgeOnGet?: boolean;
36
36
  updateAgeOnHas?: boolean;
37
37
  broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
38
+ disableInstance?: boolean;
38
39
  };
39
40
  redis?: {
40
- ttl: number;
41
+ ttl?: number;
41
42
  updateAgeOnGet?: boolean;
42
43
  client?: keyof import("vona-module-a-redis").IRedisClientRecord;
44
+ disableInstance?: boolean;
43
45
  };
44
46
  enable?: boolean;
45
47
  meta?: Omit<IOnionOptionsMeta, never> | undefined;
@@ -55,11 +57,13 @@ export declare function config(_app: VonaApplication): {
55
57
  updateAgeOnGet?: boolean;
56
58
  updateAgeOnHas?: boolean;
57
59
  broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
60
+ disableInstance?: boolean;
58
61
  };
59
62
  redis?: {
60
- ttl: number;
63
+ ttl?: number;
61
64
  updateAgeOnGet?: boolean;
62
65
  client?: keyof import("vona-module-a-redis").IRedisClientRecord;
66
+ disableInstance?: boolean;
63
67
  };
64
68
  enable?: boolean;
65
69
  meta?: Omit<IOnionOptionsMeta, never> | undefined;
package/dist/index.js CHANGED
@@ -1362,14 +1362,10 @@ class BeanModelMeta extends BeanBase {
1362
1362
  delete data[columnNameInstance];
1363
1363
  } else {
1364
1364
  delete data.iid;
1365
- if (!isNil(options?.iid)) {
1366
- data[columnNameInstance] = options?.iid;
1367
- } else {
1368
- if (!this.ctx.instance) {
1369
- throw new Error('ctx.instance not exists');
1370
- }
1371
- data[columnNameInstance] = this.ctx.instance.id;
1365
+ if (!this.ctx.instance) {
1366
+ throw new Error('ctx.instance not exists');
1372
1367
  }
1368
+ data[columnNameInstance] = this.ctx.instance.id;
1373
1369
  }
1374
1370
  return data;
1375
1371
  }
@@ -1398,8 +1394,8 @@ class BeanModelMeta extends BeanBase {
1398
1394
  const deleted = this._prepareDisableDeletedByOptionsSimple(options);
1399
1395
  return isNil(deleted) || Boolean(entity.deleted) === Boolean(deleted);
1400
1396
  }
1401
- _checkDisableInstanceByOptions(options) {
1402
- return options?.disableInstance ?? this.disableInstance;
1397
+ _checkDisableInstanceByOptions(_options) {
1398
+ return this.disableInstance;
1403
1399
  }
1404
1400
  _checkDisableDeletedByOptions(options) {
1405
1401
  if (this.disableDeleted) return true;
@@ -2092,7 +2088,7 @@ class ModelCacheBase extends BeanBase {
2092
2088
  }
2093
2089
  getName(table) {
2094
2090
  const clientNameReal = this.$scope.orm.service.database.prepareClientNameReal(this._model.db.clientName);
2095
- return `${this.$beanFullName}:${clientNameReal}:${table}:${this._cacheType}`;
2091
+ return `${this._model.$beanFullName}:${clientNameReal}:${table}:${this._cacheType}`;
2096
2092
  }
2097
2093
  get options() {
2098
2094
  if (this[SymbolCacheOptions] === undefined) {
@@ -2128,7 +2124,11 @@ class ModelCacheBase extends BeanBase {
2128
2124
  _cacheOptions = deepExtend({
2129
2125
  enable: this.scopeOrm.config.summer.enable,
2130
2126
  meta: this.scopeOrm.config.summer.meta,
2127
+ mem: {
2128
+ disableInstance: this._model.disableInstance
2129
+ },
2131
2130
  redis: {
2131
+ disableInstance: this._model.disableInstance,
2132
2132
  client: this.scopeOrm.config.summer.redis.client
2133
2133
  }
2134
2134
  }, configPreset, _cacheOptions, {
@@ -3127,7 +3127,6 @@ class BeanModelCache extends BeanModelCrud {
3127
3127
  const item = await cache.get(id, {
3128
3128
  get: async () => {
3129
3129
  // where: maybe contain aux key
3130
- // disableInstance: use the model options, not use options by outer
3131
3130
  return await super._get(table, where, {
3132
3131
  disableDeleted: true
3133
3132
  });
@@ -1,7 +1,7 @@
1
1
  import type { Knex } from 'knex';
2
2
  import type { VonaContext } from 'vona';
3
3
  import type { IDatabaseClientDialectRecord, IDatabaseClientRecord } from './database.ts';
4
- export type TypeDefaultClientNameFn = (ctx: VonaContext) => keyof IDatabaseClientRecord;
4
+ export type TypeDefaultClientNameFn = (ctx?: VonaContext) => keyof IDatabaseClientRecord;
5
5
  export type TypeDefaultClientName = TypeDefaultClientNameFn | keyof IDatabaseClientRecord;
6
6
  export interface ConfigDatabaseClient extends Omit<Knex.Config, 'client'> {
7
7
  client: keyof IDatabaseClientDialectRecord;
@@ -37,20 +37,18 @@ export interface IBuildModelCountParams<TRecord, _Model extends BeanModelMeta |
37
37
  joins?: IModelSelectParamsJoin<TRecord, TableNames, ColumnNames>[];
38
38
  }
39
39
  export type IModelCountParams<TRecord, Model extends BeanModelMeta = BeanModelMeta, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined> = IBuildModelCountParams<TRecord, Model, TypeEntityTableNamesOfGeneral<ModelJoins, Model>, TypeEntityTableColumnNamesOfGeneral<ModelJoins, Model>, TypeEntityTableColumnsOfGeneral<ModelJoins, Model>>;
40
- export type IModelMethodOptions = Omit<IModelMethodOptionsGeneral, 'disableInstance'>;
41
- export type IModelInsertOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = Omit<IModelInsertOptionsGeneral<TRecord, Model>, 'disableInstance'>;
42
- export type IModelUpdateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = Omit<IModelUpdateOptionsGeneral<TRecord, Model>, 'disableInstance'>;
43
- export type IModelDeleteOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = Omit<IModelDeleteOptionsGeneral<TRecord, Model>, 'disableInstance'>;
44
- export type IModelGetOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = Omit<IModelGetOptionsGeneral<TRecord, Model>, 'disableInstance'>;
45
- export type IModelMutateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = Omit<IModelMutateOptionsGeneral<TRecord, Model>, 'disableInstance'>;
40
+ export type IModelMethodOptions = IModelMethodOptionsGeneral;
41
+ export type IModelInsertOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = IModelInsertOptionsGeneral<TRecord, Model>;
42
+ export type IModelUpdateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = IModelUpdateOptionsGeneral<TRecord, Model>;
43
+ export type IModelDeleteOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = IModelDeleteOptionsGeneral<TRecord, Model>;
44
+ export type IModelGetOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = IModelGetOptionsGeneral<TRecord, Model>;
45
+ export type IModelMutateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> = IModelMutateOptionsGeneral<TRecord, Model>;
46
46
  export interface IModelMethodOptionsGeneral {
47
47
  disableDeleted?: boolean;
48
- disableInstance?: boolean;
49
48
  disableCreateTime?: boolean;
50
49
  disableUpdateTime?: boolean;
51
50
  disableCacheQuery?: boolean;
52
51
  disableCacheEntity?: boolean;
53
- iid?: number;
54
52
  deleted?: boolean;
55
53
  }
56
54
  export interface IModelInsertOptionsGeneral<_TRecord, Model extends BeanModelMeta | undefined = undefined> extends IModelMethodOptionsGeneral, IModelMutateRelationIncludeWrapper<Model> {
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.46",
4
+ "version": "5.0.47",
5
5
  "title": "a-orm",
6
6
  "vonaModule": {
7
7
  "capabilities": {