pangea-server 3.3.148 → 3.3.150
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.
|
@@ -24,7 +24,7 @@ class Db {
|
|
|
24
24
|
else {
|
|
25
25
|
const idRow = await scopedModel.findOne({
|
|
26
26
|
...baseOptions,
|
|
27
|
-
...getInclude(model, { where: filters }),
|
|
27
|
+
...getInclude(model, { idsOnly: true, where: filters }),
|
|
28
28
|
attributes: [[(0, sequelize_1.col)(`${model.name}.id`), 'id']],
|
|
29
29
|
order: getFinalOrder(order),
|
|
30
30
|
raw: true,
|
|
@@ -62,7 +62,7 @@ class Db {
|
|
|
62
62
|
let instances;
|
|
63
63
|
if (page && pageSize) {
|
|
64
64
|
const idRows = await model.findAll({
|
|
65
|
-
...
|
|
65
|
+
...this.__getFindManyBaseOptions(model, { ...options, idsOnly: true }),
|
|
66
66
|
attributes: [[(0, sequelize_1.col)(`${model.name}.id`), 'id']],
|
|
67
67
|
group: [`${model.name}.id`],
|
|
68
68
|
raw: true,
|
|
@@ -114,7 +114,7 @@ class Db {
|
|
|
114
114
|
return result;
|
|
115
115
|
}
|
|
116
116
|
__getFindManyBaseOptions(model, options = {}) {
|
|
117
|
-
const { attributes, where, searchFields, search, order, paranoid = true } = options;
|
|
117
|
+
const { attributes, idsOnly, where, searchFields, search, order, paranoid = true } = options;
|
|
118
118
|
let searchWhere;
|
|
119
119
|
if (searchFields?.length && search) {
|
|
120
120
|
const searchWords = search.split(/\s+/).filter(Boolean);
|
|
@@ -128,7 +128,7 @@ class Db {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
return {
|
|
131
|
-
...getInclude(model, { attributes, where: { ...where, ...searchWhere } }),
|
|
131
|
+
...getInclude(model, { attributes, idsOnly, where: { ...where, ...searchWhere } }),
|
|
132
132
|
order: getFinalOrder(order),
|
|
133
133
|
paranoid,
|
|
134
134
|
subQuery: false,
|
|
@@ -290,7 +290,7 @@ function getInclude(model, config = {}, relDepth = new Map()) {
|
|
|
290
290
|
includeOptions.push({
|
|
291
291
|
model: relModel,
|
|
292
292
|
as: relName,
|
|
293
|
-
attributes:
|
|
293
|
+
attributes: config.attributes || config.idsOnly ? [] : undefined,
|
|
294
294
|
required: rel.required,
|
|
295
295
|
paranoid: rel.paranoid,
|
|
296
296
|
...getInclude(relModel, { ...config, where: relWhere }, newRelDepth),
|