riatsilaR
Convex Community16mo ago
6 replies
riatsila

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".

const tasks =  await ctx.db.query("tasks")
                        .withIndex("by_project", (q) => q.eq("project_id", projectId))
                        .order("asc")
                        .collect();
            console.log(tasks);
            return tasks;

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!
Was this page helpful?