video-abuse.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
  2. import { AttributesOnly } from '@shared/typescript-utils'
  3. import { VideoDetails } from '@shared/models'
  4. import { VideoModel } from '../video/video'
  5. import { AbuseModel } from './abuse'
  6. @Table({
  7. tableName: 'videoAbuse',
  8. indexes: [
  9. {
  10. fields: [ 'abuseId' ]
  11. },
  12. {
  13. fields: [ 'videoId' ]
  14. }
  15. ]
  16. })
  17. export class VideoAbuseModel extends Model<Partial<AttributesOnly<VideoAbuseModel>>> {
  18. @CreatedAt
  19. createdAt: Date
  20. @UpdatedAt
  21. updatedAt: Date
  22. @AllowNull(true)
  23. @Default(null)
  24. @Column
  25. startAt: number
  26. @AllowNull(true)
  27. @Default(null)
  28. @Column
  29. endAt: number
  30. @AllowNull(true)
  31. @Default(null)
  32. @Column(DataType.JSONB)
  33. deletedVideo: VideoDetails
  34. @ForeignKey(() => AbuseModel)
  35. @Column
  36. abuseId: number
  37. @BelongsTo(() => AbuseModel, {
  38. foreignKey: {
  39. allowNull: false
  40. },
  41. onDelete: 'cascade'
  42. })
  43. Abuse: AbuseModel
  44. @ForeignKey(() => VideoModel)
  45. @Column
  46. videoId: number
  47. @BelongsTo(() => VideoModel, {
  48. foreignKey: {
  49. allowNull: true
  50. },
  51. onDelete: 'set null'
  52. })
  53. Video: VideoModel
  54. }