adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

allow to sort by relationships

Open wojtek-krysiak opened this issue 3 years ago • 2 comments

It is required - has to be done either systematically in the admin-bro core, or allow a simple way of enhancing filters

Blocker: #251

wojtek-krysiak avatar Sep 26 '20 01:09 wojtek-krysiak

Filtering and sorting by relationships would probably require our adapters:

  • @adminjs/typeorm
  • @adminjs/sequelize
  • @adminjs/mikroorm
  • @adminjs/prisma
  • @adminjs/objection
  • @adminjs/sql to run JOINs in queries which would break the current functionality where you can assign relationships between multiple different databases. Filtering and sorting post-query would in turn break the pagination.

Suggestions how to resolve the above concerns are welcome.

dziraf avatar Jul 04 '23 09:07 dziraf

@dziraf Maybe create some additional column that would contain the sorting key - for example id, or maybe some other column of the entity - and then sort by this column? To explain it better, you would have something like this: Post: id: 1 title: Test category: relation to Category _category_sort: TestCategory

Category: id: 1 name: TestCategory

The only downside of that is that you need to keep the sort column updated.

fatidian1 avatar Oct 09 '23 06:10 fatidian1