I have a route called date
where I list all posts of the entered date.
ie: /date/26-12-2015
Then I implemented rudimentary paging so I don't show all the data at once. ie: /date/26-12-2015/2
for page two
Now this all works, but I wanted to add a route which counts all articles of the day with /date/26-12-2015/count
but the route think it's a page parameter.
What is the best option? Do I filter the page param if it contains 'count' or what is the preferred way of routing this?
This is my code:
router.get('/:date/:page', function(req, res){
var db = req.db;
var collection = db.get('collectionXYZ');
collection.find([...], function(e, docs){
res.json(docs);
});
});
// this gets skipped (because it thinks it's a parameter to the page route?)
router.get('/:date/count', function(req, res){
var dateStart = new Date(req.params.date);
var db = req.db;
var collection = db.get('collectionXYZ');
collection.count([...], function(e, docs){
res.json(docs);
});
});