import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
import { AccountModel } from '../account/account'
import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
import { AccountModel } from '../account/account'
import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos'
import { getSort } from '../utils'
import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos'
import { getSort } from '../utils'
- model: () => VideoModel,
- required: true,
- include: [
- { model: () => VideoFileModel }
- ]
+ model: VideoModel.scope([ VideoScopeNames.WITH_THUMBNAILS, VideoScopeNames.WITH_FILES ]),
+ required: true
- return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findAndCountAll(query)
- .then(({ rows, count }) => ({ total: count, data: rows }))
+ return Promise.all([
+ VideoChangeOwnershipModel.scope(ScopeNames.WITH_ACCOUNTS).count(query),
+ VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]).findAll(query)
+ ]).then(([ count, rows ]) => ({ total: count, data: rows }))