Luke
Luke
CCConvex Community
Created by Luke on 1/17/2024 in #support-community
Access Clerk Organization in Query
The webhook approach seems to have worked for me, thanks
5 replies
CCConvex Community
Created by Luke on 1/17/2024 in #support-community
Access Clerk Organization in Query
OK thanks for getting back to me, I will look into it
5 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Thanks for the support
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Coming from a background of several Firebase projects and most recently a Supabase project
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
PS, only been playing around with Convex for a few days but really enjoying it so far
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Love to see it
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Glad it wasn't a bug
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Can confirm that sorted it
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
That explains the union
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Let me just verify this
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Thank you!
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Oh wow, very good spot!
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
This is the relevant part of the schema
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
projects: defineTable({ title: v.string(), user: v.id("users"), isArchived: v.boolean(), parentProject: v.optional(v.id("projects")), icon: v.optional(v.string()), isFavorited: v.boolean(), }) .index("by_user", ["user"]) .index("by_user_parent", ["user", "parentProject"]), notes: defineTable({ title: v.string(), content: v.optional(v.string()), user: v.id("users"), project: v.optional(v.id("projects")), isArchived: v.boolean(), }) .index("by_user", ["user"]) .index("by_project", ["project"]),
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
So this is the raw query without any wrappers/anything special
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
export const getById = query({ args: { projectId: v.id("projects") }, handler: async (ctx, args) => { const identity = await ctx.auth.getUserIdentity(); const project = await ctx.db.get(args.projectId); if (!project) { throw new Error("Not found"); } if (!project.isArchived) { return project; } if (!identity) { throw new Error("Not authenticated"); } const userId = identity.subject; if (project.user !== userId) { throw new Error("Unauthorized"); } const notes = await ctx.db .query("notes") .withIndex("by_project", (q) => q.eq("project", project._id)) .collect(); const x = { ...project, notes: notes, }; return x; }, });
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
I'll try removing withUser and using the intermediate variable
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
Same issue
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
(property) getById: FunctionReference<"query", "public", { projectId: Id<"projects">; }, { _id: Id<"projects">; _creationTime: number; parentProject?: Id<"projects"> | undefined; icon?: string | undefined; title: string; user: Id<"users">; isArchived: boolean; isFavorited: boolean; } | { notes: { _id: Id<"notes">; _creationTime: number; project?: Id<"projects"> | undefined; content?: string | undefined; title: string; user: Id<"users">; isArchived: boolean; }[]; _id: Id<"projects">; _creationTime: number; parentProject?: Id<"projects"> | undefined; icon?: string | undefined; title: string; user: Id<"users">; isArchived: boolean; isFavorited: boolean; }>
46 replies
CCConvex Community
Created by Luke on 10/16/2023 in #support-community
Best practices for joining data in query
I'll change both
46 replies