diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-17 21:03:00 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-17 21:03:00 +0200 |
commit | a877d5acc5c52b8667c65f725bbca9a52e40ec48 (patch) | |
tree | 20b5dd56f71c7572360807f894e85e0ab729629f /server/models | |
parent | 479f229198bdfcfd3a63d02babdddaa8b2209ccb (diff) | |
download | PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.gz PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.zst PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.zip |
Add ability to sort videos list
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/videos.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/models/videos.js b/server/models/videos.js index 250ad3952..9cac8edda 100644 --- a/server/models/videos.js +++ b/server/models/videos.js | |||
@@ -80,8 +80,9 @@ function get (id, callback) { | |||
80 | }) | 80 | }) |
81 | } | 81 | } |
82 | 82 | ||
83 | function list (start, count, callback) { | 83 | function list (start, count, sort, callback) { |
84 | VideosDB.find({}).skip(start).limit(start + count).exec(function (err, videosList) { | 84 | VideosDB.find({}).skip(start).limit(start + count).sort(sort) |
85 | .exec(function (err, videosList) { | ||
85 | if (err) { | 86 | if (err) { |
86 | logger.error('Cannot get the list of the videos.') | 87 | logger.error('Cannot get the list of the videos.') |
87 | return callback(err) | 88 | return callback(err) |
@@ -129,8 +130,8 @@ function removeByIds (ids, callback) { | |||
129 | VideosDB.remove({ _id: { $in: ids } }, callback) | 130 | VideosDB.remove({ _id: { $in: ids } }, callback) |
130 | } | 131 | } |
131 | 132 | ||
132 | function search (name, start, count, callback) { | 133 | function search (name, start, count, sort, callback) { |
133 | VideosDB.find({ name: new RegExp(name) }).skip(start).limit(start + count) | 134 | VideosDB.find({ name: new RegExp(name) }).skip(start).limit(start + count).sort(sort) |
134 | .exec(function (err, videos) { | 135 | .exec(function (err, videos) { |
135 | if (err) { | 136 | if (err) { |
136 | logger.error('Cannot search the videos.') | 137 | logger.error('Cannot search the videos.') |