// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
- // TODO: add indexes on searchable columns
const Video = sequelize.define('Video',
{
id: {
getDurationFromFile,
list,
listForApi,
- listByHostAndRemoteId,
listOwnedAndPopulateAuthorAndTags,
listOwnedByAuthor,
load,
+ loadByHostAndRemoteId,
loadAndPopulateAuthor,
loadAndPopulateAuthorAndPodAndTags,
searchAndPopulateAuthorAndPodAndTags
function (callback) {
const params = {
- name: video.name,
remoteId: video.id
}
through: models.VideoTag,
onDelete: 'cascade'
})
+
+ this.hasMany(models.VideoAbuse, {
+ foreignKey: {
+ name: 'videoId',
+ allowNull: false
+ },
+ onDelete: 'cascade'
+ })
}
function generateMagnetUri () {
duration: this.duration,
tags: map(this.Tags, 'name'),
thumbnailPath: constants.STATIC_PATHS.THUMBNAILS + '/' + this.getThumbnailName(),
- createdAt: this.createdAt
+ createdAt: this.createdAt,
+ updatedAt: this.updatedAt
}
return json
thumbnailData: thumbnailData.toString('binary'),
tags: map(self.Tags, 'name'),
createdAt: self.createdAt,
+ updatedAt: self.updatedAt,
extname: self.extname
}
duration: this.duration,
tags: map(this.Tags, 'name'),
createdAt: this.createdAt,
+ updatedAt: this.updatedAt,
extname: this.extname
}
})
}
-function listByHostAndRemoteId (fromHost, remoteId, callback) {
+function loadByHostAndRemoteId (fromHost, remoteId, callback) {
const query = {
where: {
remoteId: remoteId
]
}
- return this.findAll(query).asCallback(callback)
+ return this.findOne(query).asCallback(callback)
}
function listOwnedAndPopulateAuthorAndTags (callback) {