remult 0.26.9 → 0.26.11-next.0

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.
@@ -22,7 +22,7 @@ export class SqliteCoreDataProvider {
22
22
  builder.addSql(await self.getCreateTableSql(entity));
23
23
  },
24
24
  addColumn: async (entity, field) => {
25
- let e = await dbNamesOf(entity);
25
+ let e = await dbNamesOf(entity, this.wrapIdentifier);
26
26
  let sql = `alter table ${e.$entityName} add column ${self.addColumnSqlSyntax(field, e.$dbNameOf(field))}`;
27
27
  builder.addSql(sql);
28
28
  },
@@ -46,7 +46,7 @@ export class SqliteCoreDataProvider {
46
46
  }
47
47
  }
48
48
  async dropTable(entity) {
49
- let e = await dbNamesOf(entity);
49
+ let e = await dbNamesOf(entity, this.wrapIdentifier);
50
50
  let sql = 'drop table if exists ' + e.$entityName;
51
51
  if (SqlDatabase.LogToConsole)
52
52
  console.info(sql);
@@ -78,7 +78,7 @@ export class SqliteCoreDataProvider {
78
78
  supportsJsonColumnType;
79
79
  async getCreateTableSql(entity) {
80
80
  let result = '';
81
- let e = await dbNamesOf(entity);
81
+ let e = await dbNamesOf(entity, this.wrapIdentifier);
82
82
  for (const x of entity.fields) {
83
83
  if (!shouldNotCreateField(x, e) || isAutoIncrement(x)) {
84
84
  if (result.length != 0)
@@ -101,6 +101,7 @@ export class SqliteCoreDataProvider {
101
101
  return sql;
102
102
  }
103
103
  wrapIdentifier(name) {
104
- return name;
104
+ //return name
105
+ return '`' + name + '`';
105
106
  }
106
107
  }
@@ -226,7 +226,7 @@ export class RepositoryImplementation {
226
226
  refs.push(ref);
227
227
  raw.push(await ref.buildDtoForInsert());
228
228
  }
229
- return Promise.all((await this._edp.insertMany(raw)).map((item, i) => refs[i].processInsertResponseDto(item)));
229
+ return promiseAll(await this._edp.insertMany(raw), (item, i) => refs[i].processInsertResponseDto(item));
230
230
  }
231
231
  else {
232
232
  let r = [];
@@ -354,7 +354,7 @@ export class RepositoryImplementation {
354
354
  }
355
355
  async save(entity) {
356
356
  if (Array.isArray(entity)) {
357
- return Promise.all(entity.map((x) => this.save(x)));
357
+ return promiseAll(entity, (x) => this.save(x));
358
358
  }
359
359
  else {
360
360
  let ref = getEntityRef(entity, false);
@@ -476,7 +476,7 @@ export class RepositoryImplementation {
476
476
  repo._addToCache(r);
477
477
  }
478
478
  }
479
- let result = await Promise.all(rawRows.map(async (r) => await this._mapRawDataToResult(r, loadFields)));
479
+ let result = await promiseAll(rawRows, async (r) => await this._mapRawDataToResult(r, loadFields));
480
480
  for (const col of this.metadata.fields) {
481
481
  let rel = getRelationFieldInfo(col);
482
482
  let incl = col.options
@@ -972,7 +972,7 @@ class rowHelperBase {
972
972
  }
973
973
  lookups = new Map();
974
974
  async waitLoad() {
975
- await Promise.all([...this.lookups.values()].map((x) => x.waitLoad()));
975
+ await promiseAll([...this.lookups.values()], (x) => x.waitLoad());
976
976
  }
977
977
  errors;
978
978
  __assertValidity() {
@@ -1144,7 +1144,7 @@ class rowHelperBase {
1144
1144
  }
1145
1145
  }
1146
1146
  }
1147
- await Promise.all([...this.fields].map((x) => x.load()));
1147
+ await promiseAll([...this.fields], (x) => x.load());
1148
1148
  }
1149
1149
  }
1150
1150
  export class rowHelperImplementation extends rowHelperBase {
@@ -2398,3 +2398,11 @@ export function getRepository(entity) {
2398
2398
  }
2399
2399
  return entity;
2400
2400
  }
2401
+ async function promiseAll(array, mapToPromise) {
2402
+ const result = [];
2403
+ for (let index = 0; index < array.length; index++) {
2404
+ const element = array[index];
2405
+ result.push(await mapToPromise(element, index));
2406
+ }
2407
+ return result;
2408
+ }
@@ -1,8 +1,16 @@
1
1
  export {};
2
2
  //y2 - soft-delete-discussion https://discord.com/channels/975754286384418847/1230386433093533698/1230386433093533698
3
3
  //y1 - In the esm version of our tutorial - the imports are automatically .ts and not .js in react and not in vue
4
+ /*y1 - The retry on server error is too wide (error 500, basically any server error) 50 retries is annoying
5
+ - vite doesn't say proxy error, so we can't listen to that to know that we are in dev
6
+ - Our SSE has it's own separate retry every 500 ms that is also problematic
7
+ - when using concurrently - on any server error - the terminal is flooded by the error messages
4
8
  //y1 - consider id to also support keyof (id:['company','index']) - had problem with | (keyof Partial<entityType>)[] & `entity`
5
9
  //y2 - readonly key: keyof MembersOnly<entityType> & string
10
+ //y1 TODO - In the esm version of our tutorial - the imports are automatically .ts and not .js in react and not in vue
11
+ //y1 TODO - consider id to also support keyof (id:['company','index']) - had problem with | (keyof Partial<entityType>)[] & `entity`
12
+ //y1 TODO - readonly key: keyof MembersOnly<entityType> & string
13
+
6
14
  //y1 - talk about insert / update / delete with relations
7
15
  /*
8
16
  repo(Order).insert({},{
@@ -25,7 +33,6 @@ export {};
25
33
  //p1 - reconsider key typing to be keyof & string
26
34
  //p1 - article on displayValue including it's definition for entities that is used in relations
27
35
  //p2 -fix remult admin not to load the html into memory until used
28
- //y2 - JY suggestion of having generate as part of the ensure schema - not sure
29
36
  //y2 - currently for string fields we default for 255 in knex (which is their default) why not just use text (varchar max) - and only use exact length when one is provided?
30
37
  //p2 - create foreign key constraints in user code - https://codesandbox.io/p/devbox/fk-validator-tdshcs
31
38
  //p2 - admin url1 - pocketbase use /_ for the admin //{allowed?:Allowed,url?:string} also checkout the admin* as it should probably be something else and didn't work in hono
package/esm/src/sort.js CHANGED
@@ -1,4 +1,3 @@
1
- import { CompoundIdField } from './CompoundIdField.js';
2
1
  import { getRelationFieldInfo } from './remult3/relationInfoMember.js';
3
2
  /**
4
3
  * The `Sort` class is used to describe sorting criteria for queries. It is mainly used internally,
@@ -140,17 +139,12 @@ export class Sort {
140
139
  entityMetadata.options.defaultOrderBy)
141
140
  orderBy = Sort.translateOrderByToSort(entityMetadata, entityMetadata.options.defaultOrderBy);
142
141
  if (!orderBy)
143
- orderBy = new Sort({ field: entityMetadata.idMetadata.field });
144
- if (entityMetadata.idMetadata.field instanceof CompoundIdField) {
145
- for (const field of entityMetadata.idMetadata.field.fields) {
146
- if (!orderBy.Segments.find((x) => x.field == field)) {
147
- orderBy.Segments.push({ field: field });
148
- }
142
+ orderBy = new Sort();
143
+ for (const field of entityMetadata.idMetadata.fields) {
144
+ if (!orderBy.Segments.find((x) => x.field == field)) {
145
+ orderBy.Segments.push({ field: field });
149
146
  }
150
147
  }
151
- else if (!orderBy.Segments.find((x) => x.field == entityMetadata.idMetadata.field)) {
152
- orderBy.Segments.push({ field: entityMetadata.idMetadata.field });
153
- }
154
148
  return orderBy;
155
149
  }
156
150
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.26.9",
3
+ "version": "0.26.11-next.0",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -18,5 +18,5 @@ export declare class SqliteCoreDataProvider implements SqlImplementation, CanBui
18
18
  createTableIfNotExist(entity: EntityMetadata<any>): Promise<void>;
19
19
  supportsJsonColumnType?: boolean;
20
20
  private getCreateTableSql;
21
- wrapIdentifier?(name: string): string;
21
+ wrapIdentifier(name: string): string;
22
22
  }
@@ -36,7 +36,7 @@ var SqliteCoreDataProvider = /** @class */ (function () {
36
36
  var e, sql;
37
37
  return tslib_1.__generator(this, function (_a) {
38
38
  switch (_a.label) {
39
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
39
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, this.wrapIdentifier)];
40
40
  case 1:
41
41
  e = _a.sent();
42
42
  sql = "alter table ".concat(e.$entityName, " add column ").concat(self.addColumnSqlSyntax(field, e.$dbNameOf(field)));
@@ -117,7 +117,7 @@ var SqliteCoreDataProvider = /** @class */ (function () {
117
117
  var e, sql;
118
118
  return tslib_1.__generator(this, function (_a) {
119
119
  switch (_a.label) {
120
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
120
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, this.wrapIdentifier)];
121
121
  case 1:
122
122
  e = _a.sent();
123
123
  sql = 'drop table if exists ' + e.$entityName;
@@ -174,7 +174,7 @@ var SqliteCoreDataProvider = /** @class */ (function () {
174
174
  switch (_d.label) {
175
175
  case 0:
176
176
  result = '';
177
- return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
177
+ return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, this.wrapIdentifier)];
178
178
  case 1:
179
179
  e = _d.sent();
180
180
  try {
@@ -212,7 +212,8 @@ var SqliteCoreDataProvider = /** @class */ (function () {
212
212
  });
213
213
  };
214
214
  SqliteCoreDataProvider.prototype.wrapIdentifier = function (name) {
215
- return name;
215
+ //return name
216
+ return '`' + name + '`';
216
217
  };
217
218
  return SqliteCoreDataProvider;
218
219
  }());
@@ -280,20 +280,20 @@ var RepositoryImplementation = /** @class */ (function () {
280
280
  };
281
281
  RepositoryImplementation.prototype.insert = function (entity) {
282
282
  return tslib_1.__awaiter(this, void 0, void 0, function () {
283
- var refs_1, raw, entity_1, entity_1_1, item, ref, _a, _b, e_4_1, _c, _d, r, entity_2, entity_2_1, item, _e, _f, e_5_1, ref;
284
- var e_4, _g, e_5, _h;
285
- return tslib_1.__generator(this, function (_j) {
286
- switch (_j.label) {
283
+ var refs_1, raw, entity_1, entity_1_1, item, ref, _a, _b, e_4_1, _c, r, entity_2, entity_2_1, item, _d, _e, e_5_1, ref;
284
+ var e_4, _f, e_5, _g;
285
+ return tslib_1.__generator(this, function (_h) {
286
+ switch (_h.label) {
287
287
  case 0:
288
288
  if (!Array.isArray(entity)) return [3 /*break*/, 23];
289
289
  if (!this._dataProvider.isProxy) return [3 /*break*/, 13];
290
290
  refs_1 = [];
291
291
  raw = [];
292
- _j.label = 1;
292
+ _h.label = 1;
293
293
  case 1:
294
- _j.trys.push([1, 9, 10, 11]);
294
+ _h.trys.push([1, 9, 10, 11]);
295
295
  entity_1 = tslib_1.__values(entity), entity_1_1 = entity_1.next();
296
- _j.label = 2;
296
+ _h.label = 2;
297
297
  case 2:
298
298
  if (!!entity_1_1.done) return [3 /*break*/, 8];
299
299
  item = entity_1_1.value;
@@ -304,59 +304,59 @@ var RepositoryImplementation = /** @class */ (function () {
304
304
  return [3 /*break*/, 5];
305
305
  case 3: return [4 /*yield*/, this.getEntityRef(this.create(item))];
306
306
  case 4:
307
- ref = (_j.sent());
308
- _j.label = 5;
307
+ ref = (_h.sent());
308
+ _h.label = 5;
309
309
  case 5:
310
310
  refs_1.push(ref);
311
311
  _b = (_a = raw).push;
312
312
  return [4 /*yield*/, ref.buildDtoForInsert()];
313
313
  case 6:
314
- _b.apply(_a, [_j.sent()]);
315
- _j.label = 7;
314
+ _b.apply(_a, [_h.sent()]);
315
+ _h.label = 7;
316
316
  case 7:
317
317
  entity_1_1 = entity_1.next();
318
318
  return [3 /*break*/, 2];
319
319
  case 8: return [3 /*break*/, 11];
320
320
  case 9:
321
- e_4_1 = _j.sent();
321
+ e_4_1 = _h.sent();
322
322
  e_4 = { error: e_4_1 };
323
323
  return [3 /*break*/, 11];
324
324
  case 10:
325
325
  try {
326
- if (entity_1_1 && !entity_1_1.done && (_g = entity_1.return)) _g.call(entity_1);
326
+ if (entity_1_1 && !entity_1_1.done && (_f = entity_1.return)) _f.call(entity_1);
327
327
  }
328
328
  finally { if (e_4) throw e_4.error; }
329
329
  return [7 /*endfinally*/];
330
330
  case 11:
331
- _d = (_c = Promise).all;
331
+ _c = promiseAll;
332
332
  return [4 /*yield*/, this._edp.insertMany(raw)];
333
- case 12: return [2 /*return*/, _d.apply(_c, [(_j.sent()).map(function (item, i) { return refs_1[i].processInsertResponseDto(item); })])];
333
+ case 12: return [2 /*return*/, _c.apply(void 0, [_h.sent(), function (item, i) { return refs_1[i].processInsertResponseDto(item); }])];
334
334
  case 13:
335
335
  r = [];
336
- _j.label = 14;
336
+ _h.label = 14;
337
337
  case 14:
338
- _j.trys.push([14, 19, 20, 21]);
338
+ _h.trys.push([14, 19, 20, 21]);
339
339
  entity_2 = tslib_1.__values(entity), entity_2_1 = entity_2.next();
340
- _j.label = 15;
340
+ _h.label = 15;
341
341
  case 15:
342
342
  if (!!entity_2_1.done) return [3 /*break*/, 18];
343
343
  item = entity_2_1.value;
344
- _f = (_e = r).push;
344
+ _e = (_d = r).push;
345
345
  return [4 /*yield*/, this.insert(item)];
346
346
  case 16:
347
- _f.apply(_e, [_j.sent()]);
348
- _j.label = 17;
347
+ _e.apply(_d, [_h.sent()]);
348
+ _h.label = 17;
349
349
  case 17:
350
350
  entity_2_1 = entity_2.next();
351
351
  return [3 /*break*/, 15];
352
352
  case 18: return [3 /*break*/, 21];
353
353
  case 19:
354
- e_5_1 = _j.sent();
354
+ e_5_1 = _h.sent();
355
355
  e_5 = { error: e_5_1 };
356
356
  return [3 /*break*/, 21];
357
357
  case 20:
358
358
  try {
359
- if (entity_2_1 && !entity_2_1.done && (_h = entity_2.return)) _h.call(entity_2);
359
+ if (entity_2_1 && !entity_2_1.done && (_g = entity_2.return)) _g.call(entity_2);
360
360
  }
361
361
  finally { if (e_5) throw e_5.error; }
362
362
  return [7 /*endfinally*/];
@@ -368,9 +368,9 @@ var RepositoryImplementation = /** @class */ (function () {
368
368
  if (!ref.isNew())
369
369
  throw 'Item is not new';
370
370
  return [4 /*yield*/, ref.save()];
371
- case 24: return [2 /*return*/, _j.sent()];
371
+ case 24: return [2 /*return*/, _h.sent()];
372
372
  case 25: return [4 /*yield*/, this.getEntityRef(this.create(entity)).save()];
373
- case 26: return [2 /*return*/, _j.sent()];
373
+ case 26: return [2 /*return*/, _h.sent()];
374
374
  case 27: return [2 /*return*/];
375
375
  }
376
376
  });
@@ -589,7 +589,7 @@ var RepositoryImplementation = /** @class */ (function () {
589
589
  switch (_a.label) {
590
590
  case 0:
591
591
  if (!Array.isArray(entity)) return [3 /*break*/, 1];
592
- return [2 /*return*/, Promise.all(entity.map(function (x) { return _this.save(x); }))];
592
+ return [2 /*return*/, promiseAll(entity, function (x) { return _this.save(x); })];
593
593
  case 1:
594
594
  ref = (0, getEntityRef_js_1.getEntityRef)(entity, false);
595
595
  if (!ref) return [3 /*break*/, 3];
@@ -836,12 +836,12 @@ var RepositoryImplementation = /** @class */ (function () {
836
836
  }
837
837
  finally { if (e_10) throw e_10.error; }
838
838
  return [7 /*endfinally*/];
839
- case 8: return [4 /*yield*/, Promise.all(rawRows.map(function (r) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
839
+ case 8: return [4 /*yield*/, promiseAll(rawRows, function (r) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
840
840
  switch (_a.label) {
841
841
  case 0: return [4 /*yield*/, this._mapRawDataToResult(r, loadFields)];
842
842
  case 1: return [2 /*return*/, _a.sent()];
843
843
  }
844
- }); }); }))];
844
+ }); }); })];
845
845
  case 9:
846
846
  result = _j.sent();
847
847
  _loop_1 = function (col) {
@@ -1613,7 +1613,7 @@ var rowHelperBase = /** @class */ (function () {
1613
1613
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1614
1614
  return tslib_1.__generator(this, function (_a) {
1615
1615
  switch (_a.label) {
1616
- case 0: return [4 /*yield*/, Promise.all(tslib_1.__spreadArray([], tslib_1.__read(this.lookups.values()), false).map(function (x) { return x.waitLoad(); }))];
1616
+ case 0: return [4 /*yield*/, promiseAll(tslib_1.__spreadArray([], tslib_1.__read(this.lookups.values()), false), function (x) { return x.waitLoad(); })];
1617
1617
  case 1:
1618
1618
  _a.sent();
1619
1619
  return [2 /*return*/];
@@ -1886,7 +1886,7 @@ var rowHelperBase = /** @class */ (function () {
1886
1886
  }
1887
1887
  finally { if (e_29) throw e_29.error; }
1888
1888
  }
1889
- return [4 /*yield*/, Promise.all(tslib_1.__spreadArray([], tslib_1.__read(this.fields), false).map(function (x) { return x.load(); }))];
1889
+ return [4 /*yield*/, promiseAll(tslib_1.__spreadArray([], tslib_1.__read(this.fields), false), function (x) { return x.load(); })];
1890
1890
  case 1:
1891
1891
  _d.sent();
1892
1892
  return [2 /*return*/];
@@ -3853,3 +3853,28 @@ function getRepository(entity) {
3853
3853
  return entity;
3854
3854
  }
3855
3855
  exports.getRepository = getRepository;
3856
+ function promiseAll(array, mapToPromise) {
3857
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
3858
+ var result, index, element, _a, _b;
3859
+ return tslib_1.__generator(this, function (_c) {
3860
+ switch (_c.label) {
3861
+ case 0:
3862
+ result = [];
3863
+ index = 0;
3864
+ _c.label = 1;
3865
+ case 1:
3866
+ if (!(index < array.length)) return [3 /*break*/, 4];
3867
+ element = array[index];
3868
+ _b = (_a = result).push;
3869
+ return [4 /*yield*/, mapToPromise(element, index)];
3870
+ case 2:
3871
+ _b.apply(_a, [_c.sent()]);
3872
+ _c.label = 3;
3873
+ case 3:
3874
+ index++;
3875
+ return [3 /*break*/, 1];
3876
+ case 4: return [2 /*return*/, result];
3877
+ }
3878
+ });
3879
+ });
3880
+ }
@@ -2,8 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //y2 - soft-delete-discussion https://discord.com/channels/975754286384418847/1230386433093533698/1230386433093533698
4
4
  //y1 - In the esm version of our tutorial - the imports are automatically .ts and not .js in react and not in vue
5
+ /*y1 - The retry on server error is too wide (error 500, basically any server error) 50 retries is annoying
6
+ - vite doesn't say proxy error, so we can't listen to that to know that we are in dev
7
+ - Our SSE has it's own separate retry every 500 ms that is also problematic
8
+ - when using concurrently - on any server error - the terminal is flooded by the error messages
5
9
  //y1 - consider id to also support keyof (id:['company','index']) - had problem with | (keyof Partial<entityType>)[] & `entity`
6
10
  //y2 - readonly key: keyof MembersOnly<entityType> & string
11
+ //y1 TODO - In the esm version of our tutorial - the imports are automatically .ts and not .js in react and not in vue
12
+ //y1 TODO - consider id to also support keyof (id:['company','index']) - had problem with | (keyof Partial<entityType>)[] & `entity`
13
+ //y1 TODO - readonly key: keyof MembersOnly<entityType> & string
14
+
7
15
  //y1 - talk about insert / update / delete with relations
8
16
  /*
9
17
  repo(Order).insert({},{
@@ -26,7 +34,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
34
  //p1 - reconsider key typing to be keyof & string
27
35
  //p1 - article on displayValue including it's definition for entities that is used in relations
28
36
  //p2 -fix remult admin not to load the html into memory until used
29
- //y2 - JY suggestion of having generate as part of the ensure schema - not sure
30
37
  //y2 - currently for string fields we default for 255 in knex (which is their default) why not just use text (varchar max) - and only use exact length when one is provided?
31
38
  //p2 - create foreign key constraints in user code - https://codesandbox.io/p/devbox/fk-validator-tdshcs
32
39
  //p2 - admin url1 - pocketbase use /_ for the admin //{allowed?:Allowed,url?:string} also checkout the admin* as it should probably be something else and didn't work in hono
package/src/sort.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Sort = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var CompoundIdField_js_1 = require("./CompoundIdField.js");
6
5
  var relationInfoMember_js_1 = require("./remult3/relationInfoMember.js");
7
6
  /**
8
7
  * The `Sort` class is used to describe sorting criteria for queries. It is mainly used internally,
@@ -169,29 +168,24 @@ var Sort = /** @class */ (function () {
169
168
  entityMetadata.options.defaultOrderBy)
170
169
  orderBy = Sort.translateOrderByToSort(entityMetadata, entityMetadata.options.defaultOrderBy);
171
170
  if (!orderBy)
172
- orderBy = new Sort({ field: entityMetadata.idMetadata.field });
173
- if (entityMetadata.idMetadata.field instanceof CompoundIdField_js_1.CompoundIdField) {
174
- var _loop_2 = function (field) {
175
- if (!orderBy.Segments.find(function (x) { return x.field == field; })) {
176
- orderBy.Segments.push({ field: field });
177
- }
178
- };
179
- try {
180
- for (var _b = tslib_1.__values(entityMetadata.idMetadata.field.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
181
- var field = _c.value;
182
- _loop_2(field);
183
- }
171
+ orderBy = new Sort();
172
+ var _loop_2 = function (field) {
173
+ if (!orderBy.Segments.find(function (x) { return x.field == field; })) {
174
+ orderBy.Segments.push({ field: field });
184
175
  }
185
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
186
- finally {
187
- try {
188
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
189
- }
190
- finally { if (e_3) throw e_3.error; }
176
+ };
177
+ try {
178
+ for (var _b = tslib_1.__values(entityMetadata.idMetadata.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
179
+ var field = _c.value;
180
+ _loop_2(field);
191
181
  }
192
182
  }
193
- else if (!orderBy.Segments.find(function (x) { return x.field == entityMetadata.idMetadata.field; })) {
194
- orderBy.Segments.push({ field: entityMetadata.idMetadata.field });
183
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
184
+ finally {
185
+ try {
186
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
187
+ }
188
+ finally { if (e_3) throw e_3.error; }
195
189
  }
196
190
  return orderBy;
197
191
  };