/**
 * CategoryController
 *
 * @description :: Server-side logic for managing Preferences
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {
  preference: function (req, res){
    var id=req.param("id");
    User.findOne(id)
      .populate('preferences')
      .then(function (user) {
        return  res.json(user.preferences);
      })
      .catch(function (err) {
        console.log(err);
        return  res.json({ status : -1,
          error: err });
      });
  },
  categoryList:function (req, res){
    var id=req.param("id");
    Category.findOne(id)
      .populate('links')
      .then(function (category) {
        if(category){
          return  res.json(category.links);
        } else {
          return  res.json({ status : -1,
            msg: 'no such category' });
        }

      })
      .catch(function (err) {
        console.log(err);
        return  res.json({ status : -1,
          error: err });
      });
  },
  categories:function (req, res){
    Category.find({})
      .then(function (categories) {
        var result = [];
        categories.forEach(function (category) {
          result.push({
            title: category.category
          });
          return  res.json(result);
        });
      })
      .catch(function (err) {
            console.log(err);
            return res.json({
              status: -1,
              error: err
            });
      });
  }
};



@@ -1149,32 +1149,83 @@
 on (category) %7B%0A
+          console.log(%22categories = %22,categories);%0A
           result
@@ -1232,16 +1232,16 @@
 .push(%7B%0A
-
         
@@ -1279,27 +1279,37 @@
         %7D);%0A
+%0A
    
+     %7D);%0A
        retur
@@ -1302,33 +1302,32 @@
 ;%0A       return 
- 
 res.json(result)
@@ -1328,28 +1328,16 @@
 esult);%0A
-        %7D);%0A
       %7D)

update police