Hi,
I have two functions for the transport data and it works. But i would like to replace the model.data by json file.
function sendata(callback) {var connString = 'tcp://postgres:test@localhost/postgres';pg.connect(connString, function(err, client) {var sql = 'select * FROM table_example';client.query(sql, function(err, result) {callback(result);});});}function view_detail(id) {var self = this;if(id == 'new')self.view404('Blog not found ->');var Project = self.model('project').Project;Project.find({ _id: id }).populate('project').limit(1).exec(function(err, doc) {if (err) {self.view500(err);return;}if (doc.length === 0) {self.view404('Blog not found ->' + id);return;}var model = doc[0];Project.find({_id: id}).populate('project').sort({ 'created': -1 }).exec(function(err, rows) {sendata(function (featureCollection) {model.data = featureCollectionmodel.similar = rows;self.view('detail', model);});});});}
Project.find({_id: id}).populate('project').sort({ 'created': -1 }).exec(function(err, rows) {
// HERE
console.log('Project.find -->', err);
sendata(function(featureCollection) {
model.data = featureCollection
model.similar = rows;
self.view('detail', model);
});
});
function sendata(callback) {
var connString = 'tcp://postgres:test@localhost/postgres';
pg.connect(connString, function(err, client) {
// HERE
console.log('sendata ->', client);
var sql = 'select * FROM table_example';
client.query(sql, function(err, result) {
console.log('sendata -> client.query ->', err);
// HERE
callback(result);
});
});
}
I try the solution tonight.