Meteor -mysql methods are not returning the records
NickName:Sanjay Ask DateTime:2019-10-02T16:34:47

Meteor -mysql methods are not returning the records

I am new to Meteor, I am using MySQL database instead of MongoDB. I want to return mysql records from one of the Meteor Method at server and I am try to return same and at client side I want to print them into console. But it is printing as 'undefined'.

enter image description here

server.js
----------

    import { Meteor } from 'meteor/meteor';
    import mysql from 'mysql';
    import { Mongo } from 'meteor/mongo';
     Meteor.methods({
        insertJobCurrent:function(EMPLID,callback) {

            var pool = mysql.createConnection({
                host: '127.0.0.1',
                user: 'root',
                password: 'abc1234',
                database: 'dbEmployees'
                //port: '31597'
            });        

            var JobCurrent=[];
            pool.query("SELECT A.EMPLID, B.NAME, A.JOBCODE, A.DEPTID, A.JOB_ENTRY_DT, A.SUPERVISOR_ID FROM Employee A JOIN names B ON A.EMPLID=B.EMPLID WHERE A.ACTIVE='Y' AND A.EMPL_RCD=0 AND A.EMPLID='"+EMPLID +"'", function (error, results, fields){

                console.log(results); // Printing the results in Meteor console
                return results;


            });

            //return jobCurrent.find().fetch();
        }
    });



client.js
--------
    Meteor.call('insertJobCurrent',employeeID, function(err, response){
            if (err) {
                console.log("error: "+ err);
                console.log(response);
            } else{

                console.log(response); // Printing undefined
                console.log("success")
            }
        }); 

How can get the results at client side? Appreciate if anyone help me!

Copyright Notice:Content Author:「Sanjay」,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/58197985/meteor-mysql-methods-are-not-returning-the-records

More about “Meteor -mysql methods are not returning the records” related questions

Meteor -mysql methods are not returning the records

I am new to Meteor, I am using MySQL database instead of MongoDB. I want to return mysql records from one of the Meteor Method at server and I am try to return same and at client side I want to print

Show Detail

Retrieve MySQL insert id in Meteor method

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 an...

Show Detail

Meteor, stub method and meteor methods

I am using meteor, and I have a handlebar tag in my html {{displayResult}} in my client side JS file I write the helpers and stub method like this Helper Function *EDIT* displayResult:function(...

Show Detail

List Meteor methods registered with Meteor.methods()?

Wondering if there was a way to get a list of the current Meteor.methods that have been registered. for example if a post method is registered like so: Meteor.methods({ post: function() { /...

Show Detail

Meteor callbacks returning undefined

So I've recently started using Meteor.js, and although I appreciate its power, I'm having some issues with the way some of it works. I have a very basic couple of functions that I'm trying to use t...

Show Detail

Meteor method containing insert not returning record ID as result

I am writing attempting to return the id from an insert that's occurring within my Meteor.methods. Server code: Meteor.methods({ newCompanyReview: insertCompanyReview, }); function

Show Detail

Avoid security risk of Meteor collection update multi:true via Meteor.methods

Let's say I'm writing a reactive collection widget that needs to update multiple records in a collection; for example, a grid will update the "checked" state of multiple records as a result of a user

Show Detail

wrapMethod Meteor methods

I was looking into this presentation, building large meteor applications, and I like the idea of the wrapMethod(), but it seems like I can't use it like on the example. Here is my code. Meteor.meth...

Show Detail

Safe Methods in Meteor

I'm working on a messaging app using Meteor. I disabled any insert/update/remove called from the client for security reasons. The only way to insert messages now is by using Methods. Meteor.method...

Show Detail

Meteor method not returning error or result value

Here is my server side code Meteor.methods({ addSupportRequest: function (support) { Support.insert(support, function (err, id) { if (err) throw new Meteor.Error(404, "O...

Show Detail