pangea-server 1.0.47 → 1.0.49
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.
|
@@ -3,7 +3,7 @@ type AttributeField = string;
|
|
|
3
3
|
type AttributeOp = 'COUNT' | 'SUM';
|
|
4
4
|
type AttributeColumn = AttributeField | [AttributeOp, AttributeField];
|
|
5
5
|
type AttributeAlias = string;
|
|
6
|
-
type
|
|
6
|
+
type Attributes = Record<AttributeAlias, AttributeColumn>;
|
|
7
7
|
type IncludeItem = {
|
|
8
8
|
relation?: string;
|
|
9
9
|
active?: boolean;
|
|
@@ -14,13 +14,13 @@ type Group = string[];
|
|
|
14
14
|
type Order = Record<string, 'asc' | 'desc'>;
|
|
15
15
|
type FindOneOptions = {
|
|
16
16
|
scopes?: string[];
|
|
17
|
-
attributes?:
|
|
17
|
+
attributes?: Attributes;
|
|
18
18
|
include?: IncludeItem[];
|
|
19
19
|
order?: Order;
|
|
20
20
|
paranoid?: boolean;
|
|
21
21
|
};
|
|
22
22
|
type FindManyOptions<BM extends BaseModel> = {
|
|
23
|
-
attributes?:
|
|
23
|
+
attributes?: Attributes;
|
|
24
24
|
include?: IncludeItem[];
|
|
25
25
|
where?: Where<BM>;
|
|
26
26
|
searchFields?: string[];
|
|
@@ -84,7 +84,6 @@ class Db {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
const deletedAtWhere = paranoid === 'deleted' ? { deletedAt: { [_1.Ops.not]: null } } : {};
|
|
87
|
-
console.log(getFinalAttributes(attributes));
|
|
88
87
|
return {
|
|
89
88
|
attributes: getFinalAttributes(attributes),
|
|
90
89
|
...getIncludeAndWhere(model, include, { ...where, ...searchWhere, ...deletedAtWhere }),
|
|
@@ -191,19 +190,11 @@ exports.Db = Db;
|
|
|
191
190
|
function getFinalAttributes(attributes) {
|
|
192
191
|
if (!attributes)
|
|
193
192
|
return;
|
|
194
|
-
return attributes.map((
|
|
195
|
-
console.log(attribute);
|
|
196
|
-
if (typeof attribute === 'string')
|
|
197
|
-
return [(0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(attribute)), attribute];
|
|
198
|
-
console.log('[alias, column]');
|
|
199
|
-
const [alias, column] = Object.entries(attribute)[0];
|
|
200
|
-
console.log(alias, ': ', column);
|
|
193
|
+
return Object.entries(attributes).map(([alias, column]) => {
|
|
201
194
|
if (typeof column === 'string')
|
|
202
195
|
return [(0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(column)), alias];
|
|
203
|
-
console.log('[op, field]');
|
|
204
196
|
const [op, field] = column;
|
|
205
|
-
|
|
206
|
-
return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)(field)), alias];
|
|
197
|
+
return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(field))), alias];
|
|
207
198
|
});
|
|
208
199
|
}
|
|
209
200
|
function convertWhereKeys(obj) {
|