Repository navigation
Expand file tree
/
Copy pathold_code.js
More file actions
40 lines (33 loc) · 1.49 KB
/
Copy pathold_code.js
File metadata and controls
40 lines (33 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//original paginating search
router.get('/products', (req, res, next) => {
console.log(`query is ${req.query.page}`)
// return the first page by default
req.query.page = req.query.page || 1
Product
.find({})
.skip((req.query.page-1)*10)
.limit(10)
.exec((error, products) => {
console.log(res.toString())
res.send(products)
})
})
// snippets
router.get('/newroute', (req, res, next) => {
if (err) return next(err)
res.send(/*response*/)
})
// example product
// {"_id":{"$oid":"5f7616c77b108078742fc9cf"},"category":"Kids","name":"Intelligent Fresh Chair","price":660,"image":"https://via.placeholder.com/250?text=Product+Image","__v":0}
// {"_id":{"$oid":"5f7616c77b108078742fc9b7"},"category":"Clothing","name":"Practical Fresh Ball","price":22,"image":"https://via.placeholder.com/250?text=Product+Image","__v":0}
// {"_id":{"$oid":"5f7616c77b108078742fc9bc"},"category":"Health","name":"Handmade Fresh Soap","price":543,"image":"https://via.placeholder.com/250?text=Product+Image","__v":0}
// const getCategoryDropdowns =() => {
// let categoryCount = props.categories.length;
// let categoryDropdowns =[];
// //could also map with an index
// for (let p = 0; p < categoryCount; p++){
// let dropdownLinkItem = '<DropdownItem key=' + p + '><div onClick={userSearchCategory}>' + props.categories[p] + '</div></DropdownItem>';
// categoryDropdowns.push(dropdownLinkItem);
// }
// return categoryDropdowns;
// }