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 { ...@@ -30,7 +30,6 @@ export class CommentController {
} }
private addComment = async (req: Request, res: Response): Promise<void> => { private addComment = async (req: Request, res: Response): Promise<void> => {
const response = await this.service.addComment(req.body) const response = await this.service.addComment(req.body)
res.send(response) res.send(response)
} }
......
...@@ -4,8 +4,8 @@ import IPost from "./IPost"; ...@@ -4,8 +4,8 @@ import IPost from "./IPost";
export default interface IComment extends Document { export default interface IComment extends Document {
_id: ObjectId _id: ObjectId
user: IUser user: string
post: IPost post: string
comment: string comment: string
datetime: Date datetime: Date
} }
\ No newline at end of file
...@@ -2,6 +2,6 @@ import IComment from "./IComment" ...@@ -2,6 +2,6 @@ import IComment from "./IComment"
export default interface ICommentDto { export default interface ICommentDto {
comment: IComment['comment'] comment: IComment['comment']
user: string
post: string post: string
user: string
} }
\ No newline at end of file
...@@ -9,6 +9,7 @@ import IComment from '../interfaces/IComment'; ...@@ -9,6 +9,7 @@ import IComment from '../interfaces/IComment';
import ICommentDto from '../interfaces/ICommentDto'; import ICommentDto from '../interfaces/ICommentDto';
import { Comment } from '../models/Comments'; import { Comment } from '../models/Comments';
import IUser from '../interfaces/IUser'; import IUser from '../interfaces/IUser';
import UserModel from '../models/User';
export class Mongo implements IDataBase { export class Mongo implements IDataBase {
[x: string]: any; [x: string]: any;
...@@ -26,7 +27,7 @@ export class Mongo implements IDataBase { ...@@ -26,7 +27,7 @@ export class Mongo implements IDataBase {
public getPosts = async (): Promise<IResponse<IPost[] | undefined>> => { public getPosts = async (): Promise<IResponse<IPost[] | undefined>> => {
try { try {
const data = await Post.find().sort({ datetime: -1 }) const data = await Post.find()
const response: IResponse<IPost[]> = { const response: IResponse<IPost[]> = {
status: EStatuses.OK, status: EStatuses.OK,
result: data as any, result: data as any,
...@@ -141,7 +142,7 @@ export class Mongo implements IDataBase { ...@@ -141,7 +142,7 @@ export class Mongo implements IDataBase {
} }
public getCommentById = async (id: string): Promise<IResponse<IComment | undefined>> => { public getCommentById = async (id: string): Promise<IResponse<IComment | undefined>> => {
try { 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> = { const response: IResponse<IComment> = {
status: EStatuses.OK, status: EStatuses.OK,
result: data as any, 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