From 988798c762083e03f260073c46b6c2e8db32c10d Mon Sep 17 00:00:00 2001 From: mandzyuk-maryan Date: Sun, 28 Jul 2019 19:06:27 +0300 Subject: [PATCH] fix limit aricles --- src/api/controllers/article.controller.js | 2 +- src/db/models/article.model.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/controllers/article.controller.js b/src/api/controllers/article.controller.js index c943bd0..203b90c 100644 --- a/src/api/controllers/article.controller.js +++ b/src/api/controllers/article.controller.js @@ -3,7 +3,7 @@ const model = require('../../db/models/article.model'); module.exports = { // -------------GET------------- getArticles: (req, res) => { - model.readArticles(req, req.query.limit, articles => res.json(articles)); + model.readArticles(req, articles => res.json(articles)); }, getArticleById: (req, res) => { diff --git a/src/db/models/article.model.js b/src/db/models/article.model.js index aa3bc93..76281b9 100644 --- a/src/db/models/article.model.js +++ b/src/db/models/article.model.js @@ -59,7 +59,7 @@ module.exports = { }, // -------------READ------------- - readArticles: (req, limit, callback) => { + readArticles: (req, callback) => { let { query } = req; @@ -81,7 +81,7 @@ module.exports = { } ArticleModel.find(query).sort({ createDate: -1 - }).limit(parseInt(limit, 10)).exec((err, data) => { + }).limit(25).exec((err, data) => { if (!err) { callback(data); } else {