Skip to content

Commit

Permalink
fix: order should allow only model fields, not methods (#7188)
Browse files Browse the repository at this point in the history
Closes: #7178

Co-authored-by: Tomasz Rychlewicz <tomasz.rychlewicz@explaineverything.com>
  • Loading branch information
rysi3k and Tomasz Rychlewicz authored Dec 22, 2020
1 parent f019771 commit 0194193
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/common/EntityFieldsNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Interface of the entity fields names only (without functions)
*/
export type EntityFieldsNames<Entity = any> = {
[P in keyof Entity]: Entity[P] extends Function ? never : P;
}[keyof Entity];
3 changes: 2 additions & 1 deletion src/find-options/FindOneOptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {EntityFieldsNames} from "../common/EntityFieldsNames";
import {JoinOptions} from "./JoinOptions";
import {ObjectLiteral} from "../common/ObjectLiteral";
import {FindConditions} from "./FindConditions";
Expand Down Expand Up @@ -30,7 +31,7 @@ export interface FindOneOptions<Entity = any> {
/**
* Order, in which entities should be ordered.
*/
order?: { [P in keyof Entity]?: "ASC"|"DESC"|1|-1 };
order?: { [P in EntityFieldsNames<Entity>]?: "ASC"|"DESC"|1|-1 };

/**
* Enables or disables query result caching.
Expand Down

0 comments on commit 0194193

Please sign in to comment.