video-comment-abuse.ts 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
  2. import { AttributesOnly } from '@shared/typescript-utils'
  3. import { VideoCommentModel } from '../video/video-comment'
  4. import { AbuseModel } from './abuse'
  5. @Table({
  6. tableName: 'commentAbuse',
  7. indexes: [
  8. {
  9. fields: [ 'abuseId' ]
  10. },
  11. {
  12. fields: [ 'videoCommentId' ]
  13. }
  14. ]
  15. })
  16. export class VideoCommentAbuseModel extends Model<Partial<AttributesOnly<VideoCommentAbuseModel>>> {
  17. @CreatedAt
  18. createdAt: Date
  19. @UpdatedAt
  20. updatedAt: Date
  21. @ForeignKey(() => AbuseModel)
  22. @Column
  23. abuseId: number
  24. @BelongsTo(() => AbuseModel, {
  25. foreignKey: {
  26. allowNull: false
  27. },
  28. onDelete: 'cascade'
  29. })
  30. Abuse: AbuseModel
  31. @ForeignKey(() => VideoCommentModel)
  32. @Column
  33. videoCommentId: number
  34. @BelongsTo(() => VideoCommentModel, {
  35. foreignKey: {
  36. allowNull: true
  37. },
  38. onDelete: 'set null'
  39. })
  40. VideoComment: VideoCommentModel
  41. }