diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/models/video-blacklist.js | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-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.js | 89 |
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 | |||
3 | const modelUtils = require('./utils') | ||
4 | |||
5 | // --------------------------------------------------------------------------- | ||
6 | |||
7 | module.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 | |||
38 | function toFormatedJSON () { | ||
39 | return { | ||
40 | id: this.id, | ||
41 | videoId: this.videoId, | ||
42 | createdAt: this.createdAt | ||
43 | } | ||
44 | } | ||
45 | |||
46 | // ------------------------------ STATICS ------------------------------ | ||
47 | |||
48 | function associate (models) { | ||
49 | this.belongsTo(models.Video, { | ||
50 | foreignKey: 'videoId', | ||
51 | onDelete: 'cascade' | ||
52 | }) | ||
53 | } | ||
54 | |||
55 | function countTotal (callback) { | ||
56 | return this.count().asCallback(callback) | ||
57 | } | ||
58 | |||
59 | function list (callback) { | ||
60 | return this.findAll().asCallback(callback) | ||
61 | } | ||
62 | |||
63 | function 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 | |||
77 | function loadById (id, callback) { | ||
78 | return this.findById(id).asCallback(callback) | ||
79 | } | ||
80 | |||
81 | function loadByVideoId (id, callback) { | ||
82 | const query = { | ||
83 | where: { | ||
84 | videoId: id | ||
85 | } | ||
86 | } | ||
87 | |||
88 | return this.find(query).asCallback(callback) | ||
89 | } | ||