@tstdl/base 0.92.95 → 0.92.96
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.
|
@@ -76,7 +76,7 @@ export declare class EntityRepository<T extends Entity | EntityWithoutMetadata =
|
|
|
76
76
|
hardDeleteMany(ids: string[]): Promise<T[]>;
|
|
77
77
|
hardDeleteManyByQuery(query: Query<T>): Promise<T[]>;
|
|
78
78
|
getColumn(pathOrColumn: Paths<UntaggedDeep<T>> | ColumnDefinition): PgColumn;
|
|
79
|
-
convertOrderBy(
|
|
79
|
+
convertOrderBy(order: Order<T>): SQL[];
|
|
80
80
|
convertQuery(query: Query<T>): SQL;
|
|
81
81
|
mapManyToEntity(columns: InferSelect[]): Promise<T[]>;
|
|
82
82
|
mapToEntity(columns: InferSelect): Promise<T>;
|
package/orm/server/repository.js
CHANGED
|
@@ -434,9 +434,9 @@ let EntityRepository = class EntityRepository {
|
|
|
434
434
|
}
|
|
435
435
|
return this.#table[pathOrColumn.name];
|
|
436
436
|
}
|
|
437
|
-
convertOrderBy(
|
|
438
|
-
if (isArray(
|
|
439
|
-
return
|
|
437
|
+
convertOrderBy(order) {
|
|
438
|
+
if (isArray(order)) {
|
|
439
|
+
return order.map((item) => {
|
|
440
440
|
const itemIsArray = isArray(item);
|
|
441
441
|
const target = itemIsArray ? item[0] : item;
|
|
442
442
|
const column = isSQLWrapper(target) ? target : this.getColumn(target);
|
|
@@ -444,8 +444,11 @@ let EntityRepository = class EntityRepository {
|
|
|
444
444
|
return direction == 'asc' ? asc(column) : desc(column);
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
|
-
|
|
448
|
-
.
|
|
447
|
+
if (isString(order)) {
|
|
448
|
+
const column = this.getColumn(order);
|
|
449
|
+
return [asc(column)];
|
|
450
|
+
}
|
|
451
|
+
return objectEntries(order).map(([path, direction]) => {
|
|
449
452
|
const column = this.getColumn(path);
|
|
450
453
|
return direction == 'asc' ? asc(column) : desc(column);
|
|
451
454
|
});
|