video-tag.ts 539 B

123456789101112131415161718192021222324252627282930
  1. import { Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
  2. import { TagModel } from './tag'
  3. import { VideoModel } from './video'
  4. @Table({
  5. tableName: 'videoTag',
  6. indexes: [
  7. {
  8. fields: [ 'videoId' ]
  9. },
  10. {
  11. fields: [ 'tagId' ]
  12. }
  13. ]
  14. })
  15. export class VideoTagModel extends Model<VideoTagModel> {
  16. @CreatedAt
  17. createdAt: Date
  18. @UpdatedAt
  19. updatedAt: Date
  20. @ForeignKey(() => VideoModel)
  21. @Column
  22. videoId: number
  23. @ForeignKey(() => TagModel)
  24. @Column
  25. tagId: number
  26. }