Commit 93956466 authored by Рахметова Альбина's avatar Рахметова Альбина

Merge branch '#31' into 'dev'

fix

See merge request !34
parents 6852fd8d f452fbf3
......@@ -30,7 +30,6 @@ export class CommentController {
}
private addComment = async (req: Request, res: Response): Promise<void> => {
const response = await this.service.addComment(req.body)
res.send(response)
}
......
......@@ -4,8 +4,8 @@ import IPost from "./IPost";
export default interface IComment extends Document {
_id: ObjectId
user: IUser
post: IPost
user: string
post: string
comment: string
datetime: Date
}
\ No newline at end of file
......@@ -2,6 +2,6 @@ import IComment from "./IComment"
export default interface ICommentDto {
comment: IComment['comment']
user: string
post: string
user: string
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import IComment from '../interfaces/IComment';
import ICommentDto from '../interfaces/ICommentDto';
import { Comment } from '../models/Comments';
import IUser from '../interfaces/IUser';
import UserModel from '../models/User';
export class Mongo implements IDataBase {
[x: string]: any;
......@@ -26,7 +27,7 @@ export class Mongo implements IDataBase {
public getPosts = async (): Promise<IResponse<IPost[] | undefined>> => {
try {
const data = await Post.find().sort({ datetime: -1 })
const data = await Post.find()
const response: IResponse<IPost[]> = {
status: EStatuses.OK,
result: data as any,
......@@ -141,7 +142,7 @@ export class Mongo implements IDataBase {
}
public getCommentById = async (id: string): Promise<IResponse<IComment | undefined>> => {
try {
const data = await Comment.findById(id).populate('user').populate('post').sort({ datetime: -1 })
const data = await Comment.findById(id).populate('user').populate('post');
const response: IResponse<IComment> = {
status: EStatuses.OK,
result: data as any,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment