Skip to content

Commit

Permalink
feat(api): getDefaultAddress service
Browse files Browse the repository at this point in the history
  • Loading branch information
mrevanzak committed Nov 12, 2023
1 parent 7f8e4f9 commit 0be6719
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/api/src/router/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export const userRouter = createTRPCRouter({
where: (addresses, { eq }) => eq(addresses.userId, ctx.auth.userId),
});
}),
getDefaultAddress: protectedProcedure
.query(({ ctx }) => {
return ctx.db.query.addresses.findFirst({
where: (addresses, { and, eq }) => and(eq(addresses.userId, ctx.auth.userId), eq(addresses.default, true)),
});
}),
createAddress: protectedProcedure
.input(insertAddressSchema)
.query(({ input, ctx }) => {
Expand Down

0 comments on commit 0be6719

Please sign in to comment.