Skip to content

Commit

Permalink
いらないフィールドをオミット
Browse files Browse the repository at this point in the history
  • Loading branch information
eatski committed Aug 14, 2024
1 parent 64ec3f6 commit a190680
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/server/services/story/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
type StoryWithQuestionLogs,
questionExample,
} from "@/server/model/story";
import type { Story as DbStory, QuestionLog, User } from "@prisma/client";
import { User } from "@/server/model/user";
import type { Story as DbStory, QuestionLog } from "@prisma/client";
import { z } from "zod";

const hydrateQuestionExamples = (
Expand Down
21 changes: 18 additions & 3 deletions src/server/services/story/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export const getStories = nextCache(
publishedAt: "desc",
},
include: {
author: true,
author: {
select: {
id: true,
name: true,
},
},
},
})
.then((stories) => stories.map(omitStory));
Expand Down Expand Up @@ -93,7 +98,12 @@ export const getStory = ({
...createFindFirstWhereByFilter(storyId, filter),
},
include: {
author: true,
author: {
select: {
id: true,
name: true,
},
},
},
})
.then((story) => {
Expand Down Expand Up @@ -127,7 +137,12 @@ export const getStoriesWithAuthorId = async (args: {
},
],
include: {
author: true,
author: {
select: {
id: true,
name: true,
},
},
},
})
.then((stories) => stories.map(omitStory));
Expand Down
7 changes: 6 additions & 1 deletion src/server/services/story/ranking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const findStoriesToRank = async () => {
result: "Correct",
},
},
author: true,
author: {
select: {
id: true,
name: true,
},
},
},
where: createGetStoryWhere({}),
orderBy: {
Expand Down

0 comments on commit a190680

Please sign in to comment.