[ents] filter by index with a field and order by "updatedAt" instead of "_creation_time"
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!
13 Replies
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 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!
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
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
hi @ampp 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.
hey @ampp this works!, thanks so much, yet i have no idea how indexing works like this.
Would you mind sharing some document/article explaining this.
This is a popular reference https://stack.convex.dev/databases-are-spreadsheets and then https://docs.convex.dev/database/indexes/
Databases are Spreadsheets
I want to share my mental model of databases:
- Databases are just big spreadsheets
- An index is just a view of the spreadsheet sorted by one or mor...
Indexes | Convex Developer Hub
Indexes are a data structure that allow you to speed up your
Btw I fixed the types in 0.13.0, so the code that threw runtime exception no longer type checks.