CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
452 stars 39 forks source link

feat(pinia-orm): Change orderBy execution #1809

Closed CodeDredd closed 6 months ago

CodeDredd commented 6 months ago

🔗 Linked issue

closes #1461

❓ Type of change

📚 Description

This PR makes some improvements to orderBy.

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: [] }, ]



### 📝 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.