gabrielwG
Convex Community13mo ago
5 replies
gabrielw

Filtering a many:many ENT Edge

Hey all, having some issues with filtering an edge with ents. I am on convex-ents@latest, Typescript 5.7 and convex 1.13.2.

here is my query:
export const getEventsByTeamId = query({
  args: {
    teamId: v.id("teams"),
    paginationOpts: paginationOptsValidator,
    status: vEventStatus,
  },
  async handler(ctx, { teamId, paginationOpts, status }) {
    return await ctx
      .table("teams")
      .getX(teamId)
      .edge("events")
      .filter((q) => q.eq(q.field("status"), status))
      .order("asc", "startAtInMsSinceEpoch")
      .paginate(paginationOpts);
  },
});



The q argument in the filter is throwing a Type Error: Parameter 'q' implicitly has an 'any' type.
When I apply the filter on the "teams" table, the type inference is working as expected, but not when traversing the many:many edge.

Here is a more detailed error on the actual filter, it seems like the filter is trying to read a Team document, and not the Event edge.

Property 'filter' does not exist on type 'PromiseEdgeEnts<EntDataModelFromSchema<SchemaDefinition<{ teams: EntDefinition<VObject<{ name: string; isPersonal: boolean; slug: string; deletionTime?: number | undefined; }, { name: VString<string, "required">; isPersonal: VBoolean<boolean, "required">; FieldName: never; }, "required", "name" |


Thanks all.
Was this page helpful?