KyleK
Convex Community2y ago
3 replies
Kyle

Example Utility for Joining between Tables

Made a fun little helper for joining tables: https://gist.github.com/kyldvs/98aed78f96e9376b55092493a8bb0b75

// This has { _id: Id<"orgRole">, orgId: Id<"org">, ... }
const roles = await ctx.db.query("orgRole").collect();

// This has { _id: Id<"orgRole">, org: Doc<"org"> | undefined, ... }
const rolesWithOrg = await join<"orgRole", "org">(ctx.db, roles, "orgId");


Based on: https://docs.convex.dev/database/reading-data#join
Gist
join on fields between convex tables. GitHub Gist: instantly share code, notes, and snippets.
join on fields between convex tables
Was this page helpful?