MaastrichtU-BISS / lawnotation

Legal text annotation platform for researchers, legal practioners and more!
https://app.lawnotation.org
Apache License 2.0
5 stars 0 forks source link

Issues with filtering and sorting using supabase-js #6

Open eensander opened 1 year ago

eensander commented 1 year ago

Note This issue concerns the branch feature-improve-tables, until it is merged and removed

There are some problems when attempting to sort and filter using the supabase-js client, especially when referencing foreign tables:

eensander commented 7 months ago

With new insight, there's multiple possible solution directions to allow for filtering on multiple columns, where we can tackle both filtering on non-text columns and on foreign table values:

  1. Computed columns that concatenate all searched values. (Supabases recommended solution),
  2. View Table that directly contains the data that will visible to the end-user,
    • Pros:
      • We can keep using the supabase-js client in the backend,
      • We can cast enums and others with ::TEXT
      • The table contents the end-user sees better corresponds to the table definition in the View,
      • Probably faster response times, since View will be re-rendered on update (right?)
    • Cons:
      • Have to define the view in SQL, however I would prefer this over 1's cons.
  3. Direct database-interaction from the backend, using a raw connection or a query-builder,
    • Pros:
      • We keep the business logic and searchable columns in one place: the backend,
      • We can write the queries more specifically and hence do joining and casting in the backend,
    • Cons:
      • Requires implementing the dependency of a good query-builder and loading it in the context for only limited use-cases,