### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.
🔗 Linked issue
closes #1461
❓ Type of change
📚 Description
This PR makes some improvements to
orderBy
.role.name
it's now also possible to order by pivot data with some small help of
useSotrBy
const users = userRepo.with('roles').orderBy((user) => { user.roles = useSortBy(user.roles, [['pivot.level', 'asc']]) }).get()
// this returns
users = [ { id: 1, name: 'James', roles: [ { id: 2, users: [], pivot_roleUser: null, pivot: ... }, { id: 1, users: [], pivot_roleUser: null, pivot: ... }, ], }, { id: 2, name: 'Andy', roles: [ { id: 1, users: [], pivot_roleUser: null, pivot: ... }, ], }, { id: 3, name: 'David', roles: [] }, ]