noob saibotN
Convex Community16mo ago
3 replies
noob saibot

How to implement pagination with join and filtering

Given that I have these 2 tables that describes a 1-to-many relationship: "a user can be member of 1 or many groups"
defineSchema({
   groups: defineTable({
      group_name: v.string(),
   }),
   members: defineTable({
      group_id: v.id("groups),
      user_id: v.id("users") 
   })
})

What would be the convex way to implement the following
paginated
query:
get groups of user A (each page has 10 items)
. This is (a naive) equivalent
SQL
query:
SELECT G.* FROM groups G
JOIN members M ON G._id = M.group_id
WHERE M.user_id = 'A'
LIMIT 10 OFFSET __page_offset__
Was this page helpful?