Skip to content

Commit

Permalink
add db.find skip&limit variable
Browse files Browse the repository at this point in the history
  • Loading branch information
taobataoma committed Apr 3, 2017
1 parent 9e01d2e commit c50c3cc
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,17 @@ exports.delete = function (req, res) {
* @param res
*/
exports.list = function (req, res) {
Torrent.find().sort('-createdat').populate('user', 'displayName').exec(function (err, torrents) {
var skip = 0;
var limit = 0;

if (req.query.skip !== undefined) {
skip = req.query.skip;
}
if (req.query.limit !== undefined) {
limit = req.query.limit;
}

Torrent.find().sort('-createdat').populate('user', 'displayName').skip(skip).limit(limit).exec(function (err, torrents) {
if (err) {
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
Expand Down

0 comments on commit c50c3cc

Please sign in to comment.