vona-module-a-orm 5.0.45 → 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(
|
|
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;
|
package/dist/common/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
|
|
|
3
3
|
import type { TypeModelColumn, TypeModelColumns } from '../types/modelWhere.ts';
|
|
4
4
|
import type { IModelClassRecord } from '../types/onion/model.ts';
|
|
5
5
|
export declare function isRaw(raw: any): boolean;
|
|
6
|
+
export declare function isRef(ref: any): boolean;
|
|
6
7
|
export declare function getTableOrTableAlias(table: string): string;
|
|
7
8
|
export declare function getTargetColumnName(column: string): string;
|
|
8
9
|
export declare function prepareColumns<TRecord>(columns?: TypeModelColumns<TRecord>): Array<TypeModelColumn<TRecord>> | undefined;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
@@ -846,6 +846,9 @@ const OpValues = Object.values(Op);
|
|
|
846
846
|
function isRaw(raw) {
|
|
847
847
|
return typeof raw?.constructor === 'function' && raw?.constructor?.name === 'Raw';
|
|
848
848
|
}
|
|
849
|
+
function isRef(ref) {
|
|
850
|
+
return typeof ref?.constructor === 'function' && ref?.constructor?.name === 'Ref';
|
|
851
|
+
}
|
|
849
852
|
function getTableOrTableAlias(table) {
|
|
850
853
|
const _table = table.toString();
|
|
851
854
|
return _table.includes(' as ') ? _table.split(' as ')[1].trim() : _table;
|
|
@@ -985,7 +988,7 @@ function _buildWhereColumn(having, knex, builder, column, value, op) {
|
|
|
985
988
|
return;
|
|
986
989
|
}
|
|
987
990
|
// raw
|
|
988
|
-
if (isRaw(value)) {
|
|
991
|
+
if (isRaw(value) || isRef(value)) {
|
|
989
992
|
_buildWhereColumnOpNormal(having, knex, builder, column, value, op ?? Op.eq);
|
|
990
993
|
return;
|
|
991
994
|
}
|
|
@@ -1359,14 +1362,10 @@ class BeanModelMeta extends BeanBase {
|
|
|
1359
1362
|
delete data[columnNameInstance];
|
|
1360
1363
|
} else {
|
|
1361
1364
|
delete data.iid;
|
|
1362
|
-
if (!
|
|
1363
|
-
|
|
1364
|
-
} else {
|
|
1365
|
-
if (!this.ctx.instance) {
|
|
1366
|
-
throw new Error('ctx.instance not exists');
|
|
1367
|
-
}
|
|
1368
|
-
data[columnNameInstance] = this.ctx.instance.id;
|
|
1365
|
+
if (!this.ctx.instance) {
|
|
1366
|
+
throw new Error('ctx.instance not exists');
|
|
1369
1367
|
}
|
|
1368
|
+
data[columnNameInstance] = this.ctx.instance.id;
|
|
1370
1369
|
}
|
|
1371
1370
|
return data;
|
|
1372
1371
|
}
|
|
@@ -1395,8 +1394,8 @@ class BeanModelMeta extends BeanBase {
|
|
|
1395
1394
|
const deleted = this._prepareDisableDeletedByOptionsSimple(options);
|
|
1396
1395
|
return isNil(deleted) || Boolean(entity.deleted) === Boolean(deleted);
|
|
1397
1396
|
}
|
|
1398
|
-
_checkDisableInstanceByOptions(
|
|
1399
|
-
return
|
|
1397
|
+
_checkDisableInstanceByOptions(_options) {
|
|
1398
|
+
return this.disableInstance;
|
|
1400
1399
|
}
|
|
1401
1400
|
_checkDisableDeletedByOptions(options) {
|
|
1402
1401
|
if (this.disableDeleted) return true;
|
|
@@ -2089,7 +2088,7 @@ class ModelCacheBase extends BeanBase {
|
|
|
2089
2088
|
}
|
|
2090
2089
|
getName(table) {
|
|
2091
2090
|
const clientNameReal = this.$scope.orm.service.database.prepareClientNameReal(this._model.db.clientName);
|
|
2092
|
-
return `${this.$beanFullName}:${clientNameReal}:${table}:${this._cacheType}`;
|
|
2091
|
+
return `${this._model.$beanFullName}:${clientNameReal}:${table}:${this._cacheType}`;
|
|
2093
2092
|
}
|
|
2094
2093
|
get options() {
|
|
2095
2094
|
if (this[SymbolCacheOptions] === undefined) {
|
|
@@ -2125,7 +2124,11 @@ class ModelCacheBase extends BeanBase {
|
|
|
2125
2124
|
_cacheOptions = deepExtend({
|
|
2126
2125
|
enable: this.scopeOrm.config.summer.enable,
|
|
2127
2126
|
meta: this.scopeOrm.config.summer.meta,
|
|
2127
|
+
mem: {
|
|
2128
|
+
disableInstance: this._model.disableInstance
|
|
2129
|
+
},
|
|
2128
2130
|
redis: {
|
|
2131
|
+
disableInstance: this._model.disableInstance,
|
|
2129
2132
|
client: this.scopeOrm.config.summer.redis.client
|
|
2130
2133
|
}
|
|
2131
2134
|
}, configPreset, _cacheOptions, {
|
|
@@ -3124,7 +3127,6 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3124
3127
|
const item = await cache.get(id, {
|
|
3125
3128
|
get: async () => {
|
|
3126
3129
|
// where: maybe contain aux key
|
|
3127
|
-
// disableInstance: use the model options, not use options by outer
|
|
3128
3130
|
return await super._get(table, where, {
|
|
3129
3131
|
disableDeleted: true
|
|
3130
3132
|
});
|
|
@@ -4125,4 +4127,4 @@ const $relationMutate = {
|
|
|
4125
4127
|
belongsToMany
|
|
4126
4128
|
};
|
|
4127
4129
|
|
|
4128
|
-
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, BroadcastDatabaseClientReload, Database, DatabaseDialect, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, Errors, EventClientNameReal, EventColumnsClear, EventDatabaseClientReload, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, ScheduleSoftDeletionPrune, ScopeModuleAOrm, ServiceCacheEntity, ServiceCacheQuery, ServiceColumns, ServiceColumnsCache, ServiceDatabase, ServiceDatabaseAsyncLocalStorage, ServiceDatabaseClient, ServiceDb, ServiceEntityResolver, ServiceModelResolver, ServiceRelations, ServiceTransaction, ServiceTransactionAsyncLocalStorage, ServiceTransactionConsistency, ServiceTransactionFiber, ServiceTransactionState, SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyFieldsMore, SymbolKeyModelOptions, TransactionIsolationLevelsMap, buildWhere, config, configDefault, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isAggrColumn, isRaw, locales, prepareClassModel, prepareColumns };
|
|
4130
|
+
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, BroadcastDatabaseClientReload, Database, DatabaseDialect, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, Errors, EventClientNameReal, EventColumnsClear, EventDatabaseClientReload, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, ScheduleSoftDeletionPrune, ScopeModuleAOrm, ServiceCacheEntity, ServiceCacheQuery, ServiceColumns, ServiceColumnsCache, ServiceDatabase, ServiceDatabaseAsyncLocalStorage, ServiceDatabaseClient, ServiceDb, ServiceEntityResolver, ServiceModelResolver, ServiceRelations, ServiceTransaction, ServiceTransactionAsyncLocalStorage, ServiceTransactionConsistency, ServiceTransactionFiber, ServiceTransactionState, SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyFieldsMore, SymbolKeyModelOptions, TransactionIsolationLevelsMap, buildWhere, config, configDefault, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isAggrColumn, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
package/dist/types/config.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -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 =
|
|
41
|
-
export type IModelInsertOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> =
|
|
42
|
-
export type IModelUpdateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> =
|
|
43
|
-
export type IModelDeleteOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> =
|
|
44
|
-
export type IModelGetOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> =
|
|
45
|
-
export type IModelMutateOptions<TRecord, Model extends BeanModelMeta | undefined = undefined> =
|
|
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> {
|