Remove comment.id before inserting new ones
This commit is contained in:
parent
0c70a3b688
commit
78056e53a0
@ -45,6 +45,7 @@ export class CommentService extends BaseService implements ICommentService {
|
|||||||
.ensure('storyId')
|
.ensure('storyId')
|
||||||
.throw()
|
.throw()
|
||||||
|
|
||||||
|
delete comment.id
|
||||||
comment.parentId = 0
|
comment.parentId = 0
|
||||||
comment.userId = userId
|
comment.userId = userId
|
||||||
comment.votes = 0
|
comment.votes = 0
|
||||||
@ -53,11 +54,6 @@ export class CommentService extends BaseService implements ICommentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save(comment: IComment, userId: number) {
|
async save(comment: IComment, userId: number) {
|
||||||
|
|
||||||
comment.votes = 0
|
|
||||||
comment.spams = 0
|
|
||||||
comment.userId = userId
|
|
||||||
|
|
||||||
new Validator(comment)
|
new Validator(comment)
|
||||||
.ensure('message')
|
.ensure('message')
|
||||||
.ensure('userId')
|
.ensure('userId')
|
||||||
@ -65,6 +61,12 @@ export class CommentService extends BaseService implements ICommentService {
|
|||||||
.ensure('parentId')
|
.ensure('parentId')
|
||||||
.throw()
|
.throw()
|
||||||
|
|
||||||
|
delete comment.id
|
||||||
|
|
||||||
|
comment.votes = 0
|
||||||
|
comment.spams = 0
|
||||||
|
comment.userId = userId
|
||||||
|
|
||||||
return this.getRepository(Comment).save(comment)
|
return this.getRepository(Comment).save(comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user