Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hw92
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Болатов Ален
hw92
Commits
f452fbf3
Commit
f452fbf3
authored
Apr 04, 2023
by
Рахметова Альбина
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
6852fd8d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
6 deletions
+6
-6
comments.ts
backend/src/controllers/comments.ts
+0
-1
IComment.ts
backend/src/interfaces/IComment.ts
+2
-2
ICommentDto.ts
backend/src/interfaces/ICommentDto.ts
+1
-1
mongoose.ts
backend/src/repository/mongoose.ts
+3
-2
No files found.
backend/src/controllers/comments.ts
View file @
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
)
}
...
...
backend/src/interfaces/IComment.ts
View file @
f452fbf3
...
...
@@ -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
backend/src/interfaces/ICommentDto.ts
View file @
f452fbf3
...
...
@@ -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
backend/src/repository/mongoose.ts
View file @
f452fbf3
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment