kstulgysK
Convex Community12mo ago
9 replies
kstulgys

Should I avoid this ent query?

This is an example from ents docs:

export const listTeamInvites = query({
  args: { teamId: v.id("teams") },
  async handler(ctx, { teamId }) {
    return await ctx
      .table("teams")
      .getX(teamId)
      .edge("invites")
      .map(async (invite) => ({
        _id: invite._id,
        email: invite.email,
        role: (await invite.edge("role")).name,
      })); // `{ _id: Id<"invites">, email: string, role: string }[]`
  },
});


It's likely there are just a few roles so I guess it's fine but let's say there are many roles or let's say it's ever growing collection i.e "posts". Should I try to avoid this kind of query and doing i.e title: (await invite.edge("posts")).title

My example might be silly with "posts" but just want to make a point and to understand if this is ok for larger collections then just "roles".
Was this page helpful?