Skip to content

Commit

Permalink
fix(server): solved posts likes type error
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-ojha committed Jul 1, 2022
1 parent 4eab149 commit 4e76335
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions controllers/post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default {
_id: any;
})[]
) => {
return userPosts.map((post) => {
return userPosts.map((post: UserDocumentPosts) => {
const lastCommented = post.comments.by[post.comments.by.length - 1];
if (lastCommented) {
const numbers = commentedUser.filter(
Expand All @@ -358,7 +358,7 @@ export default {
caption: post.caption,
date: post.date,
id: post.id,
likes: post.likes,
likes: post.likes as ResPonseUserPost["likes"],
comments: {
No: post.comments.No,
by: [
Expand Down
4 changes: 2 additions & 2 deletions controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
caption: post.caption,
date: post.date,
id: post.id,
likes: post.likes,
likes: post.likes as ResPonseUserPost["likes"],
comments: {
No: post.comments.No,
by: [
Expand Down Expand Up @@ -528,7 +528,7 @@ export default {
caption: post.caption,
date: post.date,
id: post.id,
likes: post.likes,
likes: post.likes as ResPonseUserPost["likes"],
comments: {
No: post.comments.No,
by: [
Expand Down
2 changes: 1 addition & 1 deletion interface/userDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type UserDocumentPosts = {
No: number;
by: UserDocumentPostsComments[] | [];
};
date?: Date;
date: Date;
};

export interface RootUserNewPosts {
Expand Down
8 changes: 6 additions & 2 deletions models/userDetail_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import userStories from "./userStories.js";
import userNotifications from "./userNotifications.js";
import userTokens from "./userTokens.js";
import userBirthday from "./userBirthday.js";
import {
UserDocumentPosts,
UserDocumentStories,
} from "../interface/userDocument.js";

const userDetailSchema = new mongoose.Schema<
SchemaMethodInstance,
Expand Down Expand Up @@ -117,8 +121,8 @@ userDetailSchema.methods.generateAuthToken = async function (): Promise<
};

userDetailSchema.methods.uploadPost = async function (
postData: object,
userStoryDetail: object
postData: UserDocumentPosts,
userStoryDetail: UserDocumentStories
) {
try {
let resPost: UpdateResult;
Expand Down

0 comments on commit 4e76335

Please sign in to comment.