pangea-server 1.0.59 → 1.0.61

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.
@@ -16,7 +16,7 @@ class Db {
16
16
  const { scopes, attributes, order, paranoid = true } = options;
17
17
  const scopedModel = scopes?.length ? model.scope(...scopes) : model;
18
18
  const baseOptions = {
19
- attributes: getFinalAttributes(attributes),
19
+ attributes: getFinalAttributes(model, attributes),
20
20
  paranoid,
21
21
  subQuery: false,
22
22
  transaction: this.__tx,
@@ -81,9 +81,12 @@ class Db {
81
81
  };
82
82
  }
83
83
  return {
84
- attributes: getFinalAttributes(attributes),
84
+ attributes: getFinalAttributes(model, attributes),
85
85
  ...getInclude(model, { attributes, where: { ...where, ...searchWhere } }),
86
86
  ...(group && { group: group.map(pangea_helpers_1.camelToSnake) }),
87
+ ...(group && {
88
+ group: group.map((field) => (field.includes('.') ? field : `${model.name}.${(0, pangea_helpers_1.camelToSnake)(field)}`)),
89
+ }),
87
90
  order: getFinalOrder(order),
88
91
  paranoid,
89
92
  subQuery: false,
@@ -183,14 +186,17 @@ class Db {
183
186
  }
184
187
  exports.Db = Db;
185
188
  // internal functions
186
- function getFinalAttributes(attributes) {
189
+ function getFinalAttributes(model, attributes) {
187
190
  if (!attributes)
188
191
  return;
189
192
  return Object.entries(attributes).map(([alias, column]) => {
190
- if (typeof column === 'string')
191
- return [(0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(column)), alias];
192
- const [op, field] = column;
193
- return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(field))), alias];
193
+ if (typeof column === 'string') {
194
+ const field = column.includes('.') ? column : `${model.name}.${(0, pangea_helpers_1.camelToSnake)(column)}`;
195
+ return [(0, sequelize_1.col)(field), alias];
196
+ }
197
+ const [op, fieldName] = column;
198
+ const field = fieldName.includes('.') ? fieldName : `${model.name}.${(0, pangea_helpers_1.camelToSnake)(fieldName)}`;
199
+ return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)(field)), alias];
194
200
  });
195
201
  }
196
202
  function convertWhereKeys(obj) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "1.0.59",
4
+ "version": "1.0.61",
5
5
  "files": [
6
6
  "dist"
7
7
  ],