Skip to content

Commit

Permalink
statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
HUNG-rushb committed Jan 6, 2024
1 parent f1436d5 commit de88f1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Type_Definitions/Post_Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import commonDefs from './Common_Common.js';
const postDefs = gql`
extend type Query {
allPosts: [Post]!
allPostsTimestamp: [Static]!
postInfo(data: PostInfoInput!): Post!
getNewFeed(
Expand Down Expand Up @@ -42,6 +43,11 @@ const postDefs = gql`
}
${commonDefs}
type Static {
month: String
year: String
}
type PostEdge {
node: Post
cursor: String!
Expand Down
8 changes: 8 additions & 0 deletions src/resolvers/Query/POST.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const postQuery = {
allPosts: async (parent, args, info) => {
return await prisma.post.findMany();
},
allPostsTimestamp: async (parent, args, info) => {
const a = await prisma.post.findMany();

return a.map((a) => ({
month: a.createdAt.getMonth() + 1,
year: a.createdAt.getFullYear(),
}));
},
postInfo: async (parent, args, info) => {
return await prisma.post.findUnique({
where: {
Expand Down

0 comments on commit de88f1d

Please sign in to comment.