I wrote a Total.js project.
When accessing the controller from the model, it gives an empty answer. Here is the model code.
exports.getTarifs = function(f) { // definitions/mysql.js // create a DB connection var tarifs = []; // waiting for wait('waiting') DATABASE(function (err, connection) { if (err != null) { return; } var sql ='SELECT * FROM `tarifs` WHERE `f_id` = {0}'.format(f); connection.query(sql, function (err, rows,c) { // Close connection connection.release(); if (err != null) { return; } // Shows the result on a console window tarifs.push(rows); }); }); return tarifs; };
This code is written on the controller.
var tarifs = Tarifs.getTarifs(self.config.f);