diff options
Diffstat (limited to 'server/models/video/video-blacklist.ts')
-rw-r--r-- | server/models/video/video-blacklist.ts | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 3576c96f6..8c42dbc21 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -2,7 +2,6 @@ import * as Sequelize from 'sequelize' | |||
2 | 2 | ||
3 | import { addMethodsToModel, getSort } from '../utils' | 3 | import { addMethodsToModel, getSort } from '../utils' |
4 | import { | 4 | import { |
5 | BlacklistedVideoClass, | ||
6 | BlacklistedVideoInstance, | 5 | BlacklistedVideoInstance, |
7 | BlacklistedVideoAttributes, | 6 | BlacklistedVideoAttributes, |
8 | 7 | ||
@@ -66,38 +65,39 @@ function associate (models) { | |||
66 | }) | 65 | }) |
67 | } | 66 | } |
68 | 67 | ||
69 | countTotal = function (callback: BlacklistedVideoMethods.CountTotalCallback) { | 68 | countTotal = function () { |
70 | return BlacklistedVideo.count().asCallback(callback) | 69 | return BlacklistedVideo.count() |
71 | } | 70 | } |
72 | 71 | ||
73 | list = function (callback: BlacklistedVideoMethods.ListCallback) { | 72 | list = function () { |
74 | return BlacklistedVideo.findAll().asCallback(callback) | 73 | return BlacklistedVideo.findAll() |
75 | } | 74 | } |
76 | 75 | ||
77 | listForApi = function (start: number, count: number, sort: string, callback: BlacklistedVideoMethods.ListForApiCallback) { | 76 | listForApi = function (start: number, count: number, sort: string) { |
78 | const query = { | 77 | const query = { |
79 | offset: start, | 78 | offset: start, |
80 | limit: count, | 79 | limit: count, |
81 | order: [ getSort(sort) ] | 80 | order: [ getSort(sort) ] |
82 | } | 81 | } |
83 | 82 | ||
84 | return BlacklistedVideo.findAndCountAll(query).asCallback(function (err, result) { | 83 | return BlacklistedVideo.findAndCountAll(query).then(({ rows, count }) => { |
85 | if (err) return callback(err) | 84 | return { |
86 | 85 | data: rows, | |
87 | return callback(null, result.rows, result.count) | 86 | total: count |
87 | } | ||
88 | }) | 88 | }) |
89 | } | 89 | } |
90 | 90 | ||
91 | loadById = function (id: number, callback: BlacklistedVideoMethods.LoadByIdCallback) { | 91 | loadById = function (id: number) { |
92 | return BlacklistedVideo.findById(id).asCallback(callback) | 92 | return BlacklistedVideo.findById(id) |
93 | } | 93 | } |
94 | 94 | ||
95 | loadByVideoId = function (id: string, callback: BlacklistedVideoMethods.LoadByIdCallback) { | 95 | loadByVideoId = function (id: string) { |
96 | const query = { | 96 | const query = { |
97 | where: { | 97 | where: { |
98 | videoId: id | 98 | videoId: id |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | return BlacklistedVideo.find(query).asCallback(callback) | 102 | return BlacklistedVideo.findOne(query) |
103 | } | 103 | } |