I have a module in node.js, that connect with postgres database through sequelize lib. My module code basically is:
// ofr-network/index.js
var requireDir = require('require-dir');
var models = requireDir('./models');
var network = {
  getReportsFromCity: function(cityId) {
    models.index.reports.findAll({
      where: { id: cityId },
      attributes: ['id', 'latitude', 'longitude']
    }).then(function(reports) {
      console.log('[NETWORK-OFR] Get reports from %s', cityId);
      return reports;
    }).catch(function(err){
      console.log('Error getting reports from %s', cityId);
      console.log(err);
    });
  }
}
module.exports = network;
Well, this code works fine. Now I'm trying use this module in my express application, importing and calling this method, but this code isn't return anything. I've searched, and see that I must to use promises, once this code above is async. My API method code is below:
var express = require('express');
var app = express();
var router = express.Router();
var network = require('ofr-network');
var Promise = require('bluebird');
router.get('/', function(req, res) {
  var getReports = Promise.promisify(network.getReportsFromCity, network);
  getReports(538).then(function(reports) {
    console.log('DONE');
    // this print isn't running
  }).catch(function(err){
    console.log(err);
  });
  res.render('index.html', { title: 'Title page' });
});
module.exports = router;
Someone can help me?
 
     
     
    