I’m Using Meteor.publish() on the server side to fetch data from the Mysql Database Table using the numtel mysql package.
But somehow I’m unable to sync the calls on the client side.
client/templates/main.js
var selectedData = new MysqlSubscription('selectData');
calculateData(selectedData);
//perform some calculations with the above retrieved data
function calculateData(dataset) {
//calculations logic.......
}
server/dbConnection.js
var liveDb = new LiveMysql({ host: 'localhost', post: 3306, user: 'root', password: 'root', database: 'development_data' });
Meteor.publish('selectData', function() {
return liveDb.select('select * from data_table', [{
table: "data_table"
}]);
});`
Since there is no callback for the above publish function I’m unable to sync it on the client side.
As the retrieval of the data from the db takes time the calculateData()
function is executed with the empty data and throws an error.
I’ve also used the above select statement within the Meteor.methods() as it supports callback function but it’s failing to execute with the Select
statement while it works fine with the Insert
, Update
& Delete
.
Please help…