Groupby with Convex
Hey guys, just playing with convex here for a project. Still trying to understand the way to deal with queries. I saw the group by example at the documentation. It looks like it returns all the elements and and to a reduce to group by.
I have a table with over 800 items, I just need to get the a group by list of one field. ex:
exercises: { name: "squat", muscleGroup: "hamstrings" ... } I need to get all the different values of muscleGroup. Is there any easier way so I dont send off the exercise data over the wire?
4 Replies
You can control what you send back to the client by limiting what you return from your Convex query function. If you query 800 items but only need an array of strings based on those items, create the array of strings in the query and return that.
Hum, I think I see it now. The query function is running on the convex server, will load from the "db" and return only what I send over the wire to my app.
The only downside here would be that this would count as getting all the data from the db as Database bandwidth, correct?
Correct. If you’re calling this function a lot and you see it impacting your costs you may eventually want to optimize, but I’d personally wait to see if that’s the case.
Thanks for the help