#Paginate many to many edge (ents)

7 messages · Page 1 of 1 (latest)

sharp dust
#

Hello, I don't get how to paginate a many to many query on convex-ents:

const result = username === ""
      ? await ctx.table("organizations").getX(organizationId).edge("users")
      : await ctx
        .table("users")
        .search("search_username", (q) => q.search("username", username).eq("organizationId", organizationId))
        .paginate(paginationOpts);
    return result;
````

My problem is on this line :

```await ctx.table("organizations").getX(organizationId).edge("users")`````
sharp dust
#

For now I've done this as workaround:

await ctx.table("users").filter(q => q.eq(q.field("organizationId"), organizationId)).paginate(paginationOpts)`````

But I had to add an organizationId field, and not use the edge
bright totem
sharp dust
bright totem
#

paginate is supported on 1:many edges, so since you wanted the end to be optional, another work around would be to a create a "sentinel" group, to which you assign all the users who don't have a group.

#

For your workaround: Use an index