vona-module-a-orm 5.0.82 → 5.0.84
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 +10 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isNil, catchError, safeBoolean, isClass, ensureArray, hashkey } from '@
|
|
|
7
7
|
import knex from 'knex';
|
|
8
8
|
import { BeanMutateBase } from 'vona-module-a-beanmutate';
|
|
9
9
|
import { swapDeps } from '@cabloy/deps';
|
|
10
|
-
import { prepareClassType, getTargetDecoratorRules, getTargetDecoratorRuleColumnsMap, Api, v, OrderMaxBase, OrderCoreBase, getSchemaDynamic, SymbolSchemaDynamicRefId, addSchemaDynamic, mergeFieldsOpenapiMetadata } from 'vona-module-a-
|
|
10
|
+
import { prepareClassType, getTargetDecoratorRules, getTargetDecoratorRuleColumnsMap, Api, v, OrderMaxBase, OrderCoreBase, getSchemaDynamic, SymbolSchemaDynamicRefId, addSchemaDynamic, mergeFieldsOpenapiMetadata } from 'vona-module-a-openapiutils';
|
|
11
11
|
import { ZodMetadata } from '@cabloy/zod-openapi';
|
|
12
12
|
import z from 'zod';
|
|
13
13
|
import { parseFirstWord, toLowerCaseFirstChar } from '@cabloy/word-utils';
|
|
@@ -1227,13 +1227,13 @@ function _initializerDefineProperty(e, i, r, l) {
|
|
|
1227
1227
|
});
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
-
var _dec$h, _dec2$h, _dec3$6, _dec4$4, _dec5$1, _dec6$1,
|
|
1230
|
+
var _dec$h, _dec2$h, _dec3$6, _dec4$4, _dec5$1, _dec6$1, _class$h, _descriptor$4, _descriptor2$2, _descriptor3$1;
|
|
1231
1231
|
const app$1 = useApp();
|
|
1232
1232
|
const ormConfig$1 = app$1.util.getModuleConfigRaw('a-orm');
|
|
1233
1233
|
const ordersDefault = ormConfig$1?.rest?.query?.orders?.default ?? 'createdAt,desc';
|
|
1234
1234
|
let DtoQueryBase = (_dec$h = Api.field(v.optional(), v.array(String, {
|
|
1235
1235
|
separator: ','
|
|
1236
|
-
})), _dec2$h = Reflect.metadata("design:type", Array), _dec3$6 = Api.field(v.optional(), z.looseObject({})), _dec4$4 = Reflect.metadata("design:type", Object), _dec5$1 = Api.field(v.default(ordersDefault), v.optional(), z.union([z.string(), z.array(z.array(z.string()))])), _dec6$1 =
|
|
1236
|
+
})), _dec2$h = Reflect.metadata("design:type", Array), _dec3$6 = Api.field(v.optional(), z.looseObject({})), _dec4$4 = Reflect.metadata("design:type", Object), _dec5$1 = Api.field(v.default(ordersDefault), v.optional(), z.union([z.string(), z.array(z.array(z.string()))])), _dec6$1 = Reflect.metadata("design:type", Object), _class$h = class DtoQueryBase {
|
|
1237
1237
|
constructor() {
|
|
1238
1238
|
_initializerDefineProperty(this, "columns", _descriptor$4, this);
|
|
1239
1239
|
_initializerDefineProperty(this, "where", _descriptor2$2, this);
|
|
@@ -1249,7 +1249,7 @@ let DtoQueryBase = (_dec$h = Api.field(v.optional(), v.array(String, {
|
|
|
1249
1249
|
enumerable: true,
|
|
1250
1250
|
writable: true,
|
|
1251
1251
|
initializer: null
|
|
1252
|
-
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$h.prototype, "orders", [_dec5$1, _dec6$1
|
|
1252
|
+
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$h.prototype, "orders", [_dec5$1, _dec6$1], {
|
|
1253
1253
|
configurable: true,
|
|
1254
1254
|
enumerable: true,
|
|
1255
1255
|
writable: true,
|
|
@@ -1778,6 +1778,7 @@ class BeanModelKnex extends BeanModelUtils {
|
|
|
1778
1778
|
}
|
|
1779
1779
|
async queryOne(sql, bindings) {
|
|
1780
1780
|
const res = await this.query(sql, bindings);
|
|
1781
|
+
if (!res[0]) return undefined;
|
|
1781
1782
|
return res[0];
|
|
1782
1783
|
}
|
|
1783
1784
|
}
|
|
@@ -3000,10 +3001,9 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3000
3001
|
const cache = this.cacheEntity.getInstance(table);
|
|
3001
3002
|
let items = await cache.mget(ids, {
|
|
3002
3003
|
mget: async ids => {
|
|
3003
|
-
|
|
3004
|
+
return await super._mget_original(table, ids, {
|
|
3004
3005
|
disableDeleted: true
|
|
3005
3006
|
});
|
|
3006
|
-
return items.map(item => item === undefined ? null : item);
|
|
3007
3007
|
},
|
|
3008
3008
|
db: this.db
|
|
3009
3009
|
});
|
|
@@ -3049,9 +3049,8 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3049
3049
|
}
|
|
3050
3050
|
async selectAndCount(params, options, modelJoins) {
|
|
3051
3051
|
// pageNo/pageSize
|
|
3052
|
-
const pageSize = params?.limit;
|
|
3053
|
-
|
|
3054
|
-
const pageNo = Math.floor(params.offset / pageSize) + 1;
|
|
3052
|
+
const pageSize = params?.limit ?? this.scopeOrm.config.rest.query.pageSize.default;
|
|
3053
|
+
const pageNo = Math.floor((params?.offset ?? 0) / pageSize) + 1;
|
|
3055
3054
|
// count
|
|
3056
3055
|
const paramsCount = Object.assign({}, params, {
|
|
3057
3056
|
columns: undefined,
|
|
@@ -3331,15 +3330,13 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3331
3330
|
const item = await cache.get(id, {
|
|
3332
3331
|
get: async () => {
|
|
3333
3332
|
// where: maybe contain aux key
|
|
3334
|
-
|
|
3333
|
+
return await super._get(table, where, {
|
|
3335
3334
|
disableDeleted: true
|
|
3336
3335
|
});
|
|
3337
|
-
return item === undefined ? null : item;
|
|
3338
3336
|
},
|
|
3339
3337
|
db: this.db
|
|
3340
3338
|
});
|
|
3341
|
-
if (!item) return
|
|
3342
|
-
if (!this._checkIfEntityValidByDeleted(item, options)) return undefined;
|
|
3339
|
+
if (!item || !this._checkIfEntityValidByDeleted(item, options)) return undefined;
|
|
3343
3340
|
return item;
|
|
3344
3341
|
}
|
|
3345
3342
|
__filterMGetColumns(items, columns) {
|