-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetUserFavs.js
More file actions
29 lines (27 loc) · 768 Bytes
/
getUserFavs.js
File metadata and controls
29 lines (27 loc) · 768 Bytes
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
//http://expressjs.com/guide/routing.html
var express = require('express');
var router = express.Router();
function findFavsForResults(paramsUserId, results, annonFunc){
var trueArr = [];
db.Favorite.find(paramsUserId,
function(err, favoritesByUserId) {
if (err) {
console.log(err);
//res.render("errors/404");
} else {
results.businesses.forEach(function(business){
business.isFavorited = false;
favoritesByUserId.forEach(function(favorite){
if (business.id === favorite.yelpBusId){
business.isFavorited = true;
//trueArr.push(business.id);
}
});
});
} // end lse favoritesByUserId
annonFunc(results);
return results;
}
); // end db.Favorite.find(.. {..
}
module.exports = router;