aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-13 18:10:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 18:10:46 +0200
commitfbf1134e3e6b386c9ec5a3946c61f3faf84397fb (patch)
tree9071ea72c86e83bb07d8ec681a54daff2e0eb7b9 /server/models/videos.js
parentf67e976fdccbfe6432c1176148d194c980a5585a (diff)
downloadPeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.tar.gz
PeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.tar.zst
PeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.zip
Introduce paginations in videos listing
Diffstat (limited to 'server/models/videos.js')
-rw-r--r--server/models/videos.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/models/videos.js b/server/models/videos.js
index eaea35b7f..aa9ed687d 100644
--- a/server/models/videos.js
+++ b/server/models/videos.js
@@ -76,8 +76,8 @@ function get (id, callback) {
76 }) 76 })
77} 77}
78 78
79function list (callback) { 79function list (start, count, callback) {
80 VideosDB.find(function (err, videosList) { 80 VideosDB.find({}).skip(start).limit(start + count).exec(function (err, videosList) {
81 if (err) { 81 if (err) {
82 logger.error('Cannot get the list of the videos.') 82 logger.error('Cannot get the list of the videos.')
83 return callback(err) 83 return callback(err)
@@ -125,8 +125,9 @@ function removeByIds (ids, callback) {
125 VideosDB.remove({ _id: { $in: ids } }, callback) 125 VideosDB.remove({ _id: { $in: ids } }, callback)
126} 126}
127 127
128function search (name, callback) { 128function search (name, start, count, callback) {
129 VideosDB.find({ name: new RegExp(name) }, function (err, videos) { 129 VideosDB.find({ name: new RegExp(name) }).skip(start).limit(start + count)
130 .exec(function (err, videos) {
130 if (err) { 131 if (err) {
131 logger.error('Cannot search the videos.') 132 logger.error('Cannot search the videos.')
132 return callback(err) 133 return callback(err)