aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-blacklist.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /server/models/video/video-blacklist.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/models/video/video-blacklist.ts')
-rw-r--r--server/models/video/video-blacklist.ts28
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
3import { addMethodsToModel, getSort } from '../utils' 3import { addMethodsToModel, getSort } from '../utils'
4import { 4import {
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
69countTotal = function (callback: BlacklistedVideoMethods.CountTotalCallback) { 68countTotal = function () {
70 return BlacklistedVideo.count().asCallback(callback) 69 return BlacklistedVideo.count()
71} 70}
72 71
73list = function (callback: BlacklistedVideoMethods.ListCallback) { 72list = function () {
74 return BlacklistedVideo.findAll().asCallback(callback) 73 return BlacklistedVideo.findAll()
75} 74}
76 75
77listForApi = function (start: number, count: number, sort: string, callback: BlacklistedVideoMethods.ListForApiCallback) { 76listForApi = 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
91loadById = function (id: number, callback: BlacklistedVideoMethods.LoadByIdCallback) { 91loadById = function (id: number) {
92 return BlacklistedVideo.findById(id).asCallback(callback) 92 return BlacklistedVideo.findById(id)
93} 93}
94 94
95loadByVideoId = function (id: string, callback: BlacklistedVideoMethods.LoadByIdCallback) { 95loadByVideoId = 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}