controller.on('message', function(client, message) {
// create a DB connection
var connString = 'postgres://user:1234@localhost:5432/db';
pg.connect(connString, function(err, client) {
var sql = 'select * from "test" limit 300';
client.query(sql, function(err, result) {
if (err) {
console.log(err)
self.json(err);
return;
}
var featureCollection = new FeatureCollection();
console.log(result)
for (i = 0; i < result.rows.length; i++)
{
featureCollection.features[i] = JSON.parse(result.rows[i].shape);
}
controller.send({ message: featureCollection });
return;
});
});