var config = require('../../config.js').database


// Load ORM Model
var Sequelize = require('sequelize');

// Use BBDD Mysql
var sequelize = new Sequelize(config.database, config.username, config.password,
  {
    host: config.host,
    dialect: config.dialect
  }
);


// Helper to find info about pep proxy or user
exports.search_pep_or_user = function(id) {
    var query = `SELECT email, 'user' as Source FROM "user" WHERE email=:id
                 UNION ALL
                 SELECT id, 'pep_proxy' as Source FROM pep_proxy WHERE id=:id;`

    return sequelize.query(query, {replacements: {id: id}, type: Sequelize.QueryTypes.SELECT})
}

// Helper to find info about iot or user
exports.search_iot_or_user = function(id) {
    var query = `SELECT email, 'user' as Source FROM "user" WHERE email=:id
                 UNION ALL
                 SELECT id, 'iot' as Source FROM iot WHERE id=:id;`

    return sequelize.query(query, {replacements: {id: id}, type: Sequelize.QueryTypes.SELECT})
}

@@ -530,32 +530,180 @@
  WHERE id=:id;%60%0A
+    var res = sequelize.query(query, %7Breplacements: %7Bid: id%7D, type: Sequelize.QueryTypes.SELECT%7D);%0A    console.log(%22-----------------%3E res: %22, res);
 %0A    return sequ
@@ -690,32 +690,39 @@
 es);%0A    return 
+res; //
 sequelize.query(

test with console.log@