I'm using Postgresql in one app that i'm writing ,but the model of product-family always return "undefined"
model products.js
exports.data = function(self, jsonData) {
return {
id : jsonData.codex,
name : jsonData.name,
namefamily : framework.module('model')('families').name(self,
jsonData.codfamily)
};
};
and model families.js
exports.name = function(self, codfamily) {
var db = self.database();
db.connect(function(err) {
db.query("select * from families where codex='"
+ codfamily + "'", function(err, result) {
db.end();
name=result;
});
});
return name;
};
How i can response with the result of the db.query?
Thanks a lot for a response...
exports.name = function(self, codex, callback) {
....
....
callback(result);
}
self.module('model')('my-model').data(self, codex, function(result) {
console.log(result);
});