Guest User

Untitled

a guest
Jul 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. var itemsProcessed = 0;
  2. async.forEach(categories, function(category, cb) {
  3.  
  4. Audit.find({
  5. 'category_id': category._id
  6. }, 'created_at updated_at user_Id entreprise_id nom _id category_id', function(err, auds) {
  7. category.products = [];
  8. category.count = 0;
  9. if (err) res.send(err);
  10.  
  11. category.products = auds;
  12. category.count = auds.length;
  13. itemsProcessed++;
  14.  
  15. if (itemsProcessed == categories.length) {
  16. cb();
  17. }
  18. });
  19.  
  20.  
  21. }, function() {
  22.  
  23. res.json(categories);
  24.  
  25. });
Add Comment
Please, Sign In to add comment