Skip to content

feat(core): add entity-level default orderBy option#7133

Open
B4nan wants to merge 1 commit intomasterfrom
entity-order-by
Open

feat(core): add entity-level default orderBy option#7133
B4nan wants to merge 1 commit intomasterfrom
entity-order-by

Conversation

@B4nan
Copy link
Member

@B4nan B4nan commented Jan 29, 2026

Adds orderBy option to @Entity() decorator and defineEntity that provides default ordering when querying the entity directly or when it's populated as a relation.

Precedence (highest to lowest):

  1. Runtime FindOptions.orderBy
  2. Relation-level orderBy (@OneToMany, @ManyToMany)
  3. Entity-level orderBy (@Entity)

Closes #6659

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.68%. Comparing base (b6b0f0f) to head (e59246c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7133      +/-   ##
==========================================
- Coverage   99.69%   99.68%   -0.01%     
==========================================
  Files         250      250              
  Lines       21071    21073       +2     
  Branches     5627     5627              
==========================================
+ Hits        21006    21007       +1     
- Misses         65       66       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds `orderBy` option to `@Entity()` decorator and `defineEntity` that provides default ordering when querying the entity directly or when it's populated as a relation.

Precedence (highest to lowest):
1. Runtime `FindOptions.orderBy`
2. Relation-level `orderBy` (`@OneToMany`, `@ManyToMany`)
3. Entity-level `orderBy` (`@Entity`)

Closes #6659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant