5 import { values } from 'lodash'
7 import { VIDEO_RATE_TYPES } from '../initializers'
9 // ---------------------------------------------------------------------------
11 module.exports = function (sequelize, DataTypes) {
12 const UserVideoRate = sequelize.define('UserVideoRate',
15 type: DataTypes.ENUM(values(VIDEO_RATE_TYPES)),
22 fields: [ 'videoId', 'userId', 'type' ],
37 // ------------------------------ STATICS ------------------------------
39 function associate (models) {
40 this.belongsTo(models.Video, {
48 this.belongsTo(models.User, {
57 function load (userId, videoId, transaction, callback) {
59 callback = transaction
70 const options: any = {}
71 if (transaction) options.transaction = transaction
73 return this.findOne(query, options).asCallback(callback)