Code coverage report for api/controllers/ComponentController.js

Statements: 6.25% (1 / 16)      Branches: 0% (0 / 6)      Functions: 0% (0 / 4)      Lines: 7.14% (1 / 14)      Ignored: none     

All files » api/controllers/ » ComponentController.js
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 30 31 32 33 34 35 36 37 38 39              1                                                              
/**
 * ComponentController.js 
 *
 * @description ::
 * @docs        :: http://sailsjs.org/#!documentation/controllers
 */
 
module.exports = {
  create: function(req, res, next){
    Component.create(req.params.all()).exec(function(err,created){
      if(err) return next(err);
      if(!created) return next();
      res.json({
        type: 200,
        message: 'component successfully created'
      });
    });
  },
  
  update: function(req, res){
    var socket = req.socket;
    var body = req.body;
    var id = body.id;
    delete body.id;
    delete body._csrf;
    Component.update(id,{
      data: body
    }, function(err, users) {
      // Error handling
      if (err) {
        return console.log(err);
      // Updated users successfully!
      } else {
        CollaborationService.emitMessageToGraph(socket.graphId,'action',{type:"updateComponent", id:id, data:body});
      }
    });
  }
};