vona-module-a-orm 5.0.64 → 5.0.65
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.js
CHANGED
|
@@ -3060,6 +3060,10 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3060
3060
|
return this.convertItemsToBigNumber(items);
|
|
3061
3061
|
}
|
|
3062
3062
|
async selectAndCount(params, options, modelJoins) {
|
|
3063
|
+
// pageNo/pageSize
|
|
3064
|
+
const pageSize = params?.limit;
|
|
3065
|
+
if (!pageSize) throw new Error('should specify the page size');
|
|
3066
|
+
const pageNo = Math.floor(params.offset / pageSize) + 1;
|
|
3063
3067
|
// count
|
|
3064
3068
|
const paramsCount = Object.assign({}, params, {
|
|
3065
3069
|
columns: undefined,
|
|
@@ -3076,10 +3080,15 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3076
3080
|
} else {
|
|
3077
3081
|
list = await this.select(params, options, modelJoins);
|
|
3078
3082
|
}
|
|
3083
|
+
// pageNo/pageSize/pageCount
|
|
3084
|
+
const pageCount = Math.ceil(count.div(pageSize).toNumber());
|
|
3079
3085
|
// ok
|
|
3080
3086
|
return {
|
|
3081
3087
|
list,
|
|
3082
|
-
total: count
|
|
3088
|
+
total: count,
|
|
3089
|
+
pageCount,
|
|
3090
|
+
pageSize,
|
|
3091
|
+
pageNo
|
|
3083
3092
|
};
|
|
3084
3093
|
}
|
|
3085
3094
|
async select(params, options, _modelJoins) {
|
|
@@ -4176,6 +4185,9 @@ function DtoSelectAndCount(modelLike, params) {
|
|
|
4176
4185
|
const DtoGetResult = DtoGet(modelLike, params);
|
|
4177
4186
|
Api.field(v.array(DtoGetResult))(TargetClass.prototype, 'list');
|
|
4178
4187
|
Api.field(v.bigNumber())(TargetClass.prototype, 'total');
|
|
4188
|
+
Api.field(z.number())(TargetClass.prototype, 'pageCount');
|
|
4189
|
+
Api.field(z.number())(TargetClass.prototype, 'pageSize');
|
|
4190
|
+
Api.field(z.number())(TargetClass.prototype, 'pageNo');
|
|
4179
4191
|
return TargetClass;
|
|
4180
4192
|
}
|
|
4181
4193
|
|
|
@@ -5,4 +5,7 @@ import type { TypeDtoGetResult } from './dtoGet.ts';
|
|
|
5
5
|
export interface TypeDtoSelectAndCountResult<ModelLike extends BeanModelMeta | (keyof IModelClassRecord), TOptionsRelation> {
|
|
6
6
|
list: TypeDtoGetResult<ModelLike, TOptionsRelation>[];
|
|
7
7
|
total: BigNumber;
|
|
8
|
+
pageCount: number;
|
|
9
|
+
pageSize: number;
|
|
10
|
+
pageNo: number;
|
|
8
11
|
}
|
|
@@ -101,6 +101,9 @@ export type TypeUtilGetColumnsFromRelationAndIncludeWrapper<Relation, IncludeWra
|
|
|
101
101
|
export interface TypeModelSelectAndCount<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Aggrs = undefined, Groups = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> {
|
|
102
102
|
list: TypeModelRelationResult<TRecord, TModel, TOptionsRelation, TColumns, Aggrs, Groups, Depth>[];
|
|
103
103
|
total: BigNumber;
|
|
104
|
+
pageCount: number;
|
|
105
|
+
pageSize: number;
|
|
106
|
+
pageNo: number;
|
|
104
107
|
}
|
|
105
108
|
export type TypeModelRelationResult<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Aggrs = undefined, Groups = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> = Groups extends string | string[] ? TypeModelGroupRelationResultGroups<TRecord, Aggrs, Groups, TColumns> : Aggrs extends {} ? TypeModelAggrRelationResultAggrs<Aggrs> : TypeModelRelationResult_Normal<TRecord, TModel, TOptionsRelation, TColumns, Depth>;
|
|
106
109
|
export type TypeModelRelationResult_Normal<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> = TypeUtilEntitySelector<TRecord, TypeUtilPrepareColumns<TColumns extends string | string[] ? TColumns : TypeUtilGetParamsColumns<TOptionsRelation>>> & (TModel extends BeanModelMeta ? (OmitNever<TypeModelRelationResultMergeInclude<TypeUtilGetModelOptions<TModel>, TypeUtilGetParamsInlcude<TOptionsRelation>, Depth>> & OmitNever<TypeModelRelationResultMergeWith<TypeUtilGetParamsWith<TOptionsRelation>, Depth>>) : {});
|