Skip to content

Commit

Permalink
limiting to 5 products max and installing multer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rober040992 committed Dec 25, 2024
1 parent d1cb6da commit 54fdd90
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 35 deletions.
5 changes: 2 additions & 3 deletions nodepop/controllers/homeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ export async function homeController(req, res, next) {

try {
//buscamos los params de la query para paginar
const limit = req.query.limit
const skip = req.query.skip
const limit = req.query.limit || 5 // || 5 para que aparezcan directamento un max de 5 productos
const skip = req.query.skip || 0
const filter = {
owner: userId
}

// Buscamos los productos del usuario en la base de datos
const products = await Product.list(filter, limit, skip); //en orden como en el model: http://localhost:4444/?limit=3&skip=1


//aqui dentro hay productos totales: falta implementar la logica
const totalProducts = await Product.countDocuments(filter)

Expand Down
182 changes: 152 additions & 30 deletions nodepop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions nodepop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"cross-env": "^7.0.3",
"debug": "4.3.7",
"ejs": "3.1.10",
"express": "4.21.1",
"express": "^4.21.2",
"express-session": "^1.18.1",
"http-errors": "2.0.0",
"mongoose": "^8.8.0",
"morgan": "1.10.0"
"morgan": "1.10.0",
"multer": "^1.4.5-lts.1"
},
"devDependencies": {
"standard": "17.1.2"
Expand Down

0 comments on commit 54fdd90

Please sign in to comment.