aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video-blacklist.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/models/video-blacklist.js
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/models/video-blacklist.js')
-rw-r--r--server/models/video-blacklist.js89
1 files changed, 0 insertions, 89 deletions
diff --git a/server/models/video-blacklist.js b/server/models/video-blacklist.js
deleted file mode 100644
index 02ea15760..000000000
--- a/server/models/video-blacklist.js
+++ /dev/null
@@ -1,89 +0,0 @@
1'use strict'
2
3const modelUtils = require('./utils')
4
5// ---------------------------------------------------------------------------
6
7module.exports = function (sequelize, DataTypes) {
8 const BlacklistedVideo = sequelize.define('BlacklistedVideo',
9 {},
10 {
11 indexes: [
12 {
13 fields: [ 'videoId' ],
14 unique: true
15 }
16 ],
17 classMethods: {
18 associate,
19
20 countTotal,
21 list,
22 listForApi,
23 loadById,
24 loadByVideoId
25 },
26 instanceMethods: {
27 toFormatedJSON
28 },
29 hooks: {}
30 }
31 )
32
33 return BlacklistedVideo
34}
35
36// ------------------------------ METHODS ------------------------------
37
38function toFormatedJSON () {
39 return {
40 id: this.id,
41 videoId: this.videoId,
42 createdAt: this.createdAt
43 }
44}
45
46// ------------------------------ STATICS ------------------------------
47
48function associate (models) {
49 this.belongsTo(models.Video, {
50 foreignKey: 'videoId',
51 onDelete: 'cascade'
52 })
53}
54
55function countTotal (callback) {
56 return this.count().asCallback(callback)
57}
58
59function list (callback) {
60 return this.findAll().asCallback(callback)
61}
62
63function listForApi (start, count, sort, callback) {
64 const query = {
65 offset: start,
66 limit: count,
67 order: [ modelUtils.getSort(sort) ]
68 }
69
70 return this.findAndCountAll(query).asCallback(function (err, result) {
71 if (err) return callback(err)
72
73 return callback(null, result.rows, result.count)
74 })
75}
76
77function loadById (id, callback) {
78 return this.findById(id).asCallback(callback)
79}
80
81function loadByVideoId (id, callback) {
82 const query = {
83 where: {
84 videoId: id
85 }
86 }
87
88 return this.find(query).asCallback(callback)
89}