Commit 4e5d10ed authored by Zhanara's avatar Zhanara

сортировка сдалано

parent 3736c5a2
...@@ -26,7 +26,7 @@ export class Mongo implements IDataBase { ...@@ -26,7 +26,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() const data = await Post.find().sort({ datetime: -1 })
const response: IResponse<IPost[]> = { const response: IResponse<IPost[]> = {
status: EStatuses.OK, status: EStatuses.OK,
result: data as any, result: data as any,
...@@ -141,7 +141,7 @@ export class Mongo implements IDataBase { ...@@ -141,7 +141,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'); const data = await Comment.findById(id).populate('user').populate('post').sort({ datetime: -1 })
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