J'utilise node, express et swig. Je veux être en mesure de faire une boucle basée sur currentUser
qui est une variable locale pour moi. J'ai la boucle pour fonctionner mais elle crache nos résultats pour chaque utilisateur.Boucle basée sur user.id
Voici ma boucle:
{% for ap in aps %}
<tr>
<td>{{ap.name}}</td>
<td>{{ap.manufacturer}}</td>
<td>{{ap.model}}</td>
<td>{{ap.type}}</td>
<td>{{ap.notes}}</td>
</tr>
{% endfor %}
Mon itinéraire partiel (pièces retirées pour d'autres boucles):
// show model
app.get('/dashboard/it/model',
setRender('dashboard/it/model'),
setRedirect({auth: '/login'}),
isAuthenticated,
(req, res, next) => {
AP.find({}, function(err, allAP) {
if(err){
console.log(err);
} else {
res.locals.aps = allAP; // Set the data in locals
}
});
Custom.find({}, function(err, allCustom) {
if(err){
console.log(err);
} else {
res.locals.customs = allCustom; // Set the data in locals
next();
}
});
},
dashboard.getDefault
);