get-convex / fullstack-convex

Fullstack.app implementation using Convex / Auth0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sort & Filter when querying, not client-side

vakila opened this issue · comments

  • Filters - should be easy enough
  • Add indexes to use .order() with other fields than _createdAt(#18)
  • Sort by
    • number - by_number index (is this necessary? creation time & number should be inverse order)
    • title - by_title index
    • owner - we want to order owners by name, not ID, but we don't have owner names in the tasks table so I don't think there's a way to do this at query time?
    • status - by_status index
      • how to specify an ordinal rather than alphabetical order for the index? even possible? not possible, will have to make these numbers (or add string prefixes or something) to dictate their order
      • what should the secondary ordering be?
    • comments - not sure how to do this at query time unless we copy comment counts into the tasks table & patch each time a comment is added

Capturing chat with Tom:

  • No way to provide a nonstandard order for a given index, totally determined by column type
  • If we want to order by joined data like comment count or owner name, no way to index on that so only options are to
    • pull data into memory and sort in query fn (but then we lose pagination, or need to implement some version of it ourselves)
    • [my preference, icky as it is] denormalize data, copying into tasks table and patching on every write (not so bad for comment counts as each new comment would only affect one row in tasks, but for owner names it's uglier bc many rows might need updating, plus it's PII we probably don't want to spread around)

So it really depends on what we want to showcase here, given that even though this dataset isn't huge we want to show patterns that would work also for large amounts of data, and what behavior we're expecting e.g. with the interaction between pagination & ordering

I do not feel good about the things I've done here 😆