import { addMethodsToModel, getSort } from '../utils'
import {
- VideoAbuseClass,
VideoAbuseInstance,
VideoAbuseAttributes,
} from './video-abuse-interface'
let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
+let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
let listForApi: VideoAbuseMethods.ListForApi
export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
// ------------------------------ METHODS ------------------------------
-function toFormatedJSON (this: VideoAbuseInstance) {
+toFormatedJSON = function (this: VideoAbuseInstance) {
let reporterPodHost
if (this.Pod) {
name: 'reporterPodId',
allowNull: true
},
- onDelete: 'cascade'
+ onDelete: 'CASCADE'
})
VideoAbuse.belongsTo(models.Video, {
name: 'videoId',
allowNull: false
},
- onDelete: 'cascade'
+ onDelete: 'CASCADE'
})
}
-listForApi = function (start, count, sort, callback) {
+listForApi = function (start: number, count: number, sort: string) {
const query = {
offset: start,
limit: count,
]
}
- return VideoAbuse.findAndCountAll(query).asCallback(function (err, result) {
- if (err) return callback(err)
-
- return callback(null, result.rows, result.count)
+ return VideoAbuse.findAndCountAll(query).then(({ rows, count }) => {
+ return { total: count, data: rows }
})
}
-
-