#[ents] filter by index with a field and order by "updatedAt" instead of "_creation_time"

14 messages · Page 1 of 1 (latest)

visual rapids
#

Im using ents to fetch the list of item by its indexed field, and i can only perform order based on created time.
i need the updated time!

oak walrusBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

    - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
    - Use [search.convex.dev](https://search.convex.dev) to search Docs, Stack, and Discord all at once.
    - Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
    - Avoid tagging staff unless specifically instructed.

    Thank you!
visual rapids
#

here's a snippet

#

when i add a field, updatedAt, like this, function deployed

#

i get this error runtime error

#

*ignore the function path, the error is when i add the updatedAt field on the order

shrewd mica
#

You make a new index with organizationId, and updatedAt so then its .table('mainList', 'organizationId_updatedAt', (q) => q.eq(...

#

Order only accepts asc or desc so its based on the last item in the index. And having a additional .eq/.gt for updatedAt is optional

visual rapids
#

hi @shrewd mica can you further explain? I think youre solution might work but I have no idea how it would look like and how do i get the sorted mainList based on updatedAt.

shrewd mica
visual rapids
#

hey @shrewd mica this works!, thanks so much, yet i have no idea how indexing works like this.
Would you mind sharing some document/article explaining this.

shrewd mica