I am relatively new to Node and Meteor and am trying to retrieve the insert ID of a MySQL query using the numtal:mysql package. The trouble I run into is the query function running on the server and not returning to the client. I need the ID to return to the client so I can route the client to the newly created entry.
Client:
Template.new.events({
'click .button.submit' : function(){
Meteor.call('demoFunc', function(error, result){
console.log(result);
});
},
});
Server:
Meteor.methods({
demoFunc:function(){
//construct deal object
var newDeal = {
dealer_id : 1,
client_id : 1
};
//deal query
liveDb.db.query('INSERT INTO deal SET ?', newDeal, function(err, result){
return result.returnId;
});
}
});
If I could get the result.returnId in the demoFunc method to return to the client then I would be golden. If anyone's run into anything like this or worked around this, any help would be greatly appreciated.
Copyright Notice:Content Author:「CoastalP47」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28443490/retrieve-mysql-insert-id-in-meteor-method