Skip to content

Commit

Permalink
feat: remove redundant db query in me.get (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui authored Nov 13, 2024
1 parent 56728c5 commit 6262119
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/server/modules/me/me.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
* This is an example router, you can delete this file and then update `../pages/api/trpc/[trpc].tsx`
*/
import { protectedProcedure, router } from '~/server/trpc'
import { defaultMeSelect } from './me.select'

export const meRouter = router({
get: protectedProcedure.query(async ({ ctx }) => {
return await ctx.prisma.user.findUniqueOrThrow({
where: { id: ctx.user.id },
select: defaultMeSelect,
})
// Remember to write a new query if you want to return something different than what
// the authMiddleware in protectedProcedure returns.
return ctx.user
}),
})

0 comments on commit 6262119

Please sign in to comment.