Saturday 13 May 2017

Get the value of a function parameter of another function

I am developing a website using node.js and a postgreSQL database.

A part of my code looks like this :

client.query('SELECT "Project"."Id_project" FROM "Project" WHERE "Project"."Project_name" = $1',
             [payload.Project_name],
             function(err,result) 
             {
                if (err) throw err;
                return (result.rows[0].Id_project);
             });

based on https://www.npmjs.com/package/pg

I want to get the value returned by "function(err,result)" but I don't know how to. I tried something like this but it doesn't work :

var value = client.query(...)

When I do this I have this error on my node shell :

stack: error: invalid input syntax for integer: "function (){  client.query(...) }" 

So my question is : is it possible to get the value returned by a function parameter of another function?



via Hauru

No comments:

Post a Comment