Sorting different on backend vs frontend in React
I have a weird bug where I have a query that sorts a table of tasks based on "start_date".
When logging on the backend the sort is completed correctly, but the object received on the frontend is sorted by _creationtime.
When logging on the backend the sort is completed correctly, but the object received on the frontend is sorted by _creationtime.
const tasks = useQuery(api.tasks.getByProjectId, project?._id ? {projectId: project._id}: "skip");
Can sort tasks again on the frontend, but wondering if there's anything obvious I'm missing that would cause this behaviour!4 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.
- Ask in the <#1228095053885476985> channel to get a response from <@1072591948499664996>.
- Avoid tagging staff unless specifically instructed.
Thank you!
how is the
"by_project"
index defined? i can't think of anything that would cause the sort order to change between backend and frontend; they're just opaque values so they won't be reordered.index("by_project", ["project_id", "start_date", "end_date"]) — I also tried removing "end_date" to see if anything changed
Thanks for your help, realised it was a rogue sort in place affecting the object 🫠
ah that would do it,
no worries