Skip to content

Commit fffe559

Browse files
committed
style: use ?? operator instead of conditional
1 parent 2d5240c commit fffe559

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

cli/template/extras/src/server/api/routers/post/with-auth-drizzle.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ export const postRouter = createTRPCRouter({
3232
const post = ctx.db.query.posts.findFirst({
3333
orderBy: (posts, { desc }) => [desc(posts.createdAt)],
3434
});
35-
if (post === undefined) {
36-
return null;
37-
}
38-
return post;
35+
36+
return post ?? null;
3937
}),
4038

4139
getSecretMessage: protectedProcedure.query(() => {

cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ export const postRouter = createTRPCRouter({
3434
orderBy: { createdAt: "desc" },
3535
where: { createdBy: { id: ctx.session.user.id } },
3636
});
37-
if (post === undefined) {
38-
return null;
39-
}
40-
return post;
37+
38+
return post ?? null;
4139
}),
4240

4341
getSecretMessage: protectedProcedure.query(() => {

0 commit comments

Comments
 (0)