JJ Rise
JJ Rise
TTCTheo's Typesafe Cult
Created by JJ Rise on 3/19/2023 in #questions
Looking for advice on how to fetch/load an onboarding banner
I'm using T3 inside a monorepo (turbo repo). For new users, I have a Get Started page that has a handful of checklist items. These checklist items are fetched from my database and ensure the user has finished the onboarding process. If there are still steps remaining, there is a banner at the top of the page alerting the user to finish their onboarding steps. My Question: Does anyone have any suggestions on how I can structure this so I'm not constantly running this query? Because right now, even if the user has completed all the steps, the app will still query and check to make sure all the items are complete. This in practice is good even after the user is finished onboarding because I want the banner to reappear if they delete their payment method or something. Can this be 'lazy queried' (not sure if that's a thing) or maybe run in middleware or something to where it would have minimal impact on the performance? Or maybe I'm overthinking this and I should just keep it as is? But in general I'm getting the feeling that I am running unnecessary queries and there is a better way to handle the logic here. Thanks for the help!
9 replies
TTCTheo's Typesafe Cult
Created by JJ Rise on 2/1/2023 in #questions
Issues with 'pnpm install' using t3-turbo-and-clerk
3 replies
TTCTheo's Typesafe Cult
Created by JJ Rise on 1/27/2023 in #questions
Relations between Clerk Users with Prisma db
I've been using T3 for a few months now with nextAuth... I'm attempting to use Clerk with "t3-turbo-and-clerk". The part I'm getting real tripped up on is making relations between my prisma db and Clerk Users. With create-t3 / nextAuth, that nextAuth User table is in my schema and making relations is pretty brainless, but with Clerk hosting the Users, I'm not quite sure how to make that relation. Felt like a silly question to ask, but hopefully makes sense and someone can point me in the right direction! Thanks!
13 replies
TTCTheo's Typesafe Cult
Created by JJ Rise on 1/5/2023 in #questions
add fields to session
I'm using Prisma and doing an initial query to get orgId from my User table before almost every query/mutation. Ideally I'd just like orgId to be included in my ctx/session so I can access it directly similar to ctx.session.user.id. I have orgId in my Session table already, but not sure how to map that to context/session. an example of a typical query: getLowInvWarnings: protectedProcedure.query(async ({ ctx }) => { const orgID = await ctx.prisma.user.findUnique({ where: { id: ctx.session.user.id, }, select: { orgID: true, }, }); if (!orgID?.orgID) return; const lowInvGreenCoffee = await ctx.prisma.greenCoffee.findMany({ where: { orgId: orgID?.orgID, }, select: { id: true, name: true, weight: true, minInventory: true, }, }); This is probably a noob question, but want to see other folk's thoughts on how they would handle this. Thanks!
6 replies